代码有什么问题? if条件脚本不起作用

时间:2018-04-09 20:35:16

标签: php html5

为什么if条件脚本不起作用。它重定向到dashboard.html而不运行脚本。我是php的新手。我在这段代码中犯了什么错误。或者在不使用echo

的情况下告诉问题的最佳解决方案
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "myid";
$name = $_POST["name"];
$pass = $_POST["pass"];
$email = $_POST["email"];

echo $pass;


// Create connection
$conn = new mysqli 
($servername,$username,$password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn- 
>connect_error);
} 
$sql = "INSERT INTO staff ( name, pass , email)
VALUES ('$name', '$pass', '$email')";

if ($conn->query($sql) === TRUE) {
?>
<script>
   alert('Successfully Sign up');
</script>
<?php
    header("Location: dashboard.html");
    }
else 
    {
 ?>
 <script>
    alert('Something Wrong');
 </script>
 <?php
    }
 ?>

0 个答案:

没有答案