So I'm trying to link my html to my php database but whenever I open up my browser to 'localhost/cs/staff/sign_up.php'only the message 'Firstname should not be empty' comes up. How do I fix this?
----My 'sign_up.html' code----
<body>
<form method="post" action="../sign_up.php" style="border:1px solid #ccc">
<div class="container">
<h1>Sign Up</h1>
<p>Please fill in this form to create an account.</p>
<hr>
<label for="Firstname"><b>Firstname</b></label>
<input type="text" placeholder="Enter Firstname" name="firstname" required>
<label for="Lastname"><b>Email</b></label>
<input type="text" placeholder="Enter Lastname" name="lastname" required>
<label for="email"><b>Email</b></label>
<input type="text" placeholder="Enter Email" name="email" required>
<label for="psw"><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="psw" required>
<label for="psw-repeat"><b>Repeat Password</b></label>
<input type="password" placeholder="Repeat Password" name="psw-repeat" required>
<label>
<input type="checkbox" checked="checked" name="remember" style="margin-bottom:15px"> Remember me
</label>
<p>By creating an account you agree to our <a href="#" style="color:dodgerblue">Terms & Privacy</a>.</p>
<div class="clearfix">
<button type="button" class="cancelbtn">Cancel</button>
<button type="submit" class="signupbtn">Sign Up</button>
</div>
</div>
</form>
</body>
---My 'sign_up.php' code---
<?php
$f_name = filter_input(INPUT_POST, 'firstname');
$l_name = filter_input(INPUT_POST, 'lastname');
$email = filter_input(INPUT_POST, 'email');
$password = filter_input(INPUT_POST, 'psw');
if (!empty($f_name)){
if (!empty($l_name)){
if (!empty($email)){
if (!empty($password)){
$DB_SERVER = "localhost";
$DB_USERNAME = "root";
$DB_PASSWORD = "";
$DB_NAME = "project";
// Create connection
$conn = new mysqli ($host, $dbusername, $dbpassword, $dbname);
if (mysqli_connect_error()){
die('Connect Error ('. mysqli_connect_errno() .') '
. mysqli_connect_error());
}
else{
$sql = "INSERT INTO account (firstname, lastname, email, password)
values ('$firstrname', '$lastname','$email', '$password')";
if ($conn->query($sql)){
echo "New record is inserted sucessfully";
}
else{
echo "Error: ". $sql ."
". $conn->error;
}
$conn->close();
}
}
else{
echo "Password should not be empty";
die();
}
}
else{
echo "Email should not be empty";
die();
}
}
else{
echo "Lastname should not be empty";
die();
}
}
else{
echo "Firstname should not be empty";
die();
}
?>
I'm still new at coding so sorry if the error is something really simple and noobish.