为什么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
}
?>