I'd like to verify if an user entered something in an input tag :
here is the index.php page :
<form action="email_validation.php" method="post">
<p>
Enter email : <input type="text" name="email" id="email" /><br />
<input type="submit" value="Envoyer" />
</p>
</form>
and the email_validation.php :
if(isset($_POST['email']))
{
$req = $bdd->prepare('INSERT INTO newsletter(email) VALUES(:email)');
$req->execute(array(
'email' => $entree = $_POST['email']
));
echo 'Email added';
}
else
{
echo 'Enter something';
}
It seems that my condition with isset() function is not working... when I'm testing this, "Email added" is displayed even if I'm not writing anything and a blank value is added to the database . When someone write nothing, I want to display "Enter something" and don't execute the query. I searched for hours and can't resolve this... Thanks is advance !