Insert happening several times in the database

0

I have a code that inserts into the database, but the database is inserting multiple records at once

Follow the code below:

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 inserting 4 records at once into the database.

    
asked by anonymous 22.11.2017 / 16:56

0 answers