0

Why the if condition script doesn't work. It redirect to the dashboard.html without run the script. I am new to the php. What mistake i do in this code. Or tell best solution to the problem without using 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 Answers0