0
I have a code that makes an entry in the database but, in the database is inserting several records at once
Follows code:
if($_GET["act"] == ("cad_master")) {
$startaction = 20;
}
$pega_id_viagem_unique = $_GET['id_trip_unique'];
$id_user_logado = $_SESSION['ID'];
if($startaction == 20){
if($act = "cad_master") {
$upper = implode('', range('A', 'Z')); // ABCDEFGHIJKLMNOPQRSTUVWXYZ
$lower = implode('', range('a', 'z')); // abcdefghijklmnopqrstuvwxyzy
$nums = implode('', range(0, 9)); // 0123456789
$alphaNumeric = $upper.$lower.$nums; // ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
$string = '';
$len = 30; // numero de chars
for($i = 0; $i < $len; $i++) {
$string .= $alphaNumeric[rand(0, strlen($alphaNumeric) - 1)];
}
$master = $_POST['Master'];
$booking = $_POST['Booking'];
$direcao = $_POST['Direcao'];
$pre_alerta = $_POST['Pre_alerta'];
$tipo_documento = $_POST['Tipo_documento'];
$local_emissao = $_POST['Local_emissao'];
$select_trip = mysql_query("SELECT * FROM Viagens WHERE ID_Unique='$pega_id_viagem_unique'");
while($ln = mysql_fetch_array($select_trip)) {
$show_id_viagem = $ln['ID'];
}
$insert_master = mysql_query("INSERT INTO `Masters`(`ID_Unique`, `ID_User`, `Master`, `ID_Viagem`, `ID_Viagem_Unique`, `Booking`, `Direcao`, `Pre_alerta`, `Tipo_documento`, `Local_emissao`) VALUES('".$string."', '".$id_user_logado."', '".$master."', '".$show_id_viagem."', '".$pega_id_viagem_unique."', 'Booking', '".$direcao."', '".$pre_alerta."', '".$tipo_documento."', '".$local_emissao."')");
}
}
You are entering 4 records at once in the database.
4 equal records?
– I_like_trains
Yes, 4 equal records
– William De Paula