提交数据时未显示警报框

提交数据时未显示警报框

有很多类似的问题,但是我没有任何错误,我需要进行更改。
我在代码中放入了警告框,但没有出现。
这是我的代码-

if(isset($_POST['submit'])){
    $test= "select * from stable where Email = '$Email'";

    $queryResult = $conn->query($test);
    $foundRows = $queryResult->num_rows;
    if($foundRows >= 1)
        $mailerr="Email already register";
    else {
        header("location:student.php?id=".$row['id']);

        $sql = "INSERT INTO stable
                    (Firstname,Lastname,DOB,Email,Phno,
                    Gender,Address,City,ZipCode,State,Country,
                    Hobbies,Course,id,Time,Date,IP)
        VALUES('$Firstname','$Lastname','$Dob','$Email',
                '$Phno','$Gender','$Address','$City','$Zipcode',
                '$State','$Country','$Hobby','$Course','',
                '$Time','$date','$IP')";

        if($conn->query($sql))
?>
<script> alert('Data Inserted successfully');
    window.location.href='student.php?id=<?php echo $id;?>' </script>
<?php

    }
}

最佳答案

您可以将script标签与所有js一起包装在字符串中并回显它。它会工作

        if($conn->query($sql)){
  echo "<script> alert('Data Inserted successfully')window.location.href='student.php?id="+$id+"</script>";
}

关于javascript - 提交数据时未显示警报框,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/54477734/

10-09 19:01