whenever I submit something in my form i want to check if any of the fields are empty. So far what I have is not working
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$username = $_POST['username'];
$password = $_POST['password'];
$passwordconf = $_POST['passwordconf'];
$email = $_POST['email'];
$securityq = $_POST['securityq'];
$qanswer = $_POST['qanswer'];
if(empty($firstname) || empty($lastname) || empty($username) || empty($password) || empty($passwordconf) || empty($email) || empty($securityq) || empty($qanswer))
{
echo "You did not fill out the required fields.";
}
and the form
<form name="registrationform" action="register.php">
First Name:<input type="text" name="firstname">
Last Name:<input type="text" name="lastname">
Email:<input type="text" name="email">
Username:<input type="text" name="username">
Password:<input type="password" name="password">
Confirm Password:<input type="password" name="passwordconf">
Security Question:<input type="text" name="securityq">
Answer:<input type="text" name="qanswer">
<input type="submit" name="submit" value="Register">
</form>
and heres the registation page if it helps http://www.myjournal.tk/register.html
your form is missing the method...
<form name="registrationform" action="register.php" method="post"> //here
anywyas to check the posted data u can use isset()..
Determine if a variable is set and is not NULL
if(!isset($firstname) || trim($firstname) == '')
{
echo "You did not fill out the required fields.";
}
Specify POST method in form
<form name="registrationform" action="register.php" method="post">
your form code
</form>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With