when I press sign up (without filling any fields
Here is all the code if anyone is interested to help me :
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Etego</title>
</head>
<body>
<div align="center">
<h3>Sign Up</h3>
<br /> <br /> <br />
<form method="post" action="">
<table>
<tr>
<td align="right" > <label for="username">Username</label> </td>
<td > <input type="text" placeholder="Username" id="username" name="username" /> </td>
</tr>
<!-- ------------------------------------------------------------------------------------------------------- -->
<tr>
<td align="right" > <label for="email">Email</label> </td>
<td > <input type="email" placeholder="email" id="email" name="email" /> </td>
</tr>
<!-- ------------------------------------------------------------------------------------------------------- -->
<tr>
<td align="right" > <label for="email2">Confirm Email</label> </td>
<td > <input type="email" placeholder="re-enter email" id="email2" name="email2" /> </td>
</tr>
<!-- ------------------------------------------------------------------------------------------------------ -->
<tr>
<td align="right" > <label for="password">Password</label> </td>
<td > <input type="password" placeholder="password" id="password" name="password" /> </td>
</tr>
<!--------------------------------------------------------------------------------------------------------- -->
<tr>
<td align="right" > <label for="password2">Confirm Password</label> </td>
<td > <input type="password" placeholder="re-enter Password" id="password2" name="password2" /> </td>
</tr>
<!-- ------------------------------------------------------------------------------------------------------- -->
<tr>
<td>
<p>
<td>
What is your Gender?
<select name="formGender">
<option value="NS">non specified</option>
<option value="M">Male</option>
<option value="F">Female</option>
</select>
</td>
<td > <input type="hidden" placeholder="" id="gender" name="gender" /> </td>
</p>
</td>
</tr>
<!-- ------------------------------------------------------------------------------------------------------- -->
<tr>
<td></td>
<td>
<br />
<input type="submit" name="signup" value="Sign Up">
<input type="hidden" name="sign" value="true">
</td>
</tr>
</table>
</form>
</div>
</body>
</html>
<?php
$bdd = new PDO ('mysql:host=127.0.0.1;dbname=members', 'root' , '');
$gender = htmlspecialchars($_POST['gender']);
$username = htmlspecialchars($_POST['username']);
$email = htmlspecialchars($_POST['email']);
$email2 = htmlspecialchars($_POST['email2']);
$password = sha1($_POST['password']);
$password2 = sha1($_POST['password2']);
$reqemail = $bdd->prepare("SELECT * FROM members WHERE email = ?");
$reqemail->execute(array($email));
$emailexist = $reqemail->rowCount();
if($emailexist == 0) {
$passwordlenght = strlen($password);
if($passwordlenght >= 4) {
$usernamelenght = strlen($username);
if($usernamelenght <= 25) {
if($email == $email2) {
if($password == $password2) {
if (filter_var($email, FILTER_VALIDATE_EMAIL )) {
$insertmbr = $bdd->prepare("INSERT INTO members(username, email, password, gender) VALUES(?, ?, ?, ?)");
$insertmbr->execute(array($username, $email, $password, $gender));
echo "<p> <font color=red font face='arial' size='3pt'>Your account has been created</font> </p>";
header('location:login.php');
} else {
echo "<p> <font color=red font face='arial' size='3pt'>Your email isnt valid!</font> </p>";
}
} else {
echo "<p> <font color=red font face='arial' size='3pt'>Your confirmation password doesnt match with your password</font> </p>";
}
} else {
echo "<p> <font color=red font face='arial' size='3pt'>Your confirmation email doesnt match with your email</font> </p>";
}
} else {
echo "<p> <font color=red font face='arial' size='3pt'>Your username may not exceed 25 characters</font> </p>";
}
} else {
echo "<p> <font color=red font face='arial' size='3pt'>Your password must be 5 characters or more</font> </p>";
}
} else {
echo "<p> <font color=red font face='arial' size='3pt'>Your email is already being used by a user</font> </p>";
}
//---------------------------------------------EMPTY FIELDS ERROR-----------------------------------------------------------------------------------------
if (!empty($_POST['sign']) && $_POST['sign']=="true")
if($_POST['sign']=="true") {
if(empty($_POST['username'])) {
echo "<p> <font color=red font face='arial' size='3pt'>please go back and fill username</font> </p>";
} else {
$username = $_POST['username'];
}
if(empty($_POST['email'])) {
echo "<p> <font color=red font face='arial' size='3pt'>please go back and fill email</font> </p>";
} else {
$email = $_POST['email'];
}
if(empty($_POST['email2'])) {
echo "<p> <font color=red font face='arial' size='3pt'>please go back and fill confirmation email</font> </p>";
} else {
$email2 = $_POST['email2'];
}
if(empty($_POST['password'])) {
echo "<p> <font color=red font face='arial' size='3pt'>please go back and fill password</font> </p>";
} else {
$password = $_POST['password'];
}
if(empty($_POST['password2'])) {
echo "<p> <font color=red font face='arial' size='3pt'>please go back and fill confirmation password</font> </p>";
} else {
$password2 = $_POST['password2'];
}
}
?>
I use phpmyadmin and "members" is my browse, it has the id, username, password, email and I recently added gender thing.