间歇地重复在mysql表中输入

时间:2019-07-05 07:34:52

标签: mysql google-chrome

以下添加的代码在我的电脑上非常有效。最近,当我检查数据库时,它使用不同的pc / chrome浏览器创建了多个条目。

我尝试使用其他PC。问题是间歇性的

  <?php
if($_POST['submit']=="Update"){
    $ps = array();
        foreach($_POST['pstatus'] AS $val) {
        $ps[] = mysqli_real_escape_string($con, $val);//For sanitation of the array
        }
    $log = array();
        foreach($_POST['logs'] AS $val) {
        $log[] = mysqli_real_escape_string($con, $val);//For sanitation of the array
        }
    $sc = array();
        foreach($_POST['scale'] AS $val) {
        $sc[] = mysqli_real_escape_string($con, $val);//For sanitation of the array
        }
    $btt = array();
        foreach($_POST['bt'] AS $val) {
        $btt[] = mysqli_real_escape_string($con, $val);//For sanitation of the array
        }
    $tpp = array();
        foreach($_POST['tp'] AS $val) {
        $tpp[] = mysqli_real_escape_string($con, $val);//For sanitation of the array
        }
    $dt = array();
        foreach($_POST['dt'] AS $val) {
        $dt[] = mysqli_real_escape_string($con, $val);//For sanitation of the array
        }
    $ln = array();
        foreach($_POST['lno'] AS $val) {
        $ln[] = mysqli_real_escape_string($con, $val);//For sanitation of the array
        }
    $user = $_SESSION["Fname"].' '.$_SESSION["Lname"];
    $cquery="";
    $count = count($log);
            date_default_timezone_set('Asia/Kolkata');//Indian standard time
            for($i=0;$i<$count;$i++)
                {
                    $date = date("Y-m-d",strtotime($dt[$i]));// to convert date array string to date mysql
                    $cquery .= "insert into logs(pid,pstatus,log,scale,bottom,top,date,lno,adby) values(".$_POST['id'].",'".$ps[$i]."','".$log[$i]."','".$sc[$i]."','".$btt[$i]."','".$tpp[$i]."','".$date."','".$ln[$i]."','".$user."');";
                }// end of for loop
    if($con->multi_query($cquery)){
        header('Location: log_lib.php');
    }
    else{
        echo "Logs Details Saving failed";
    }
}

?>

0 个答案:

没有答案