i want to display an error message if the form is submitted without an email address given, but i am having problems since the form starts out with no value in the email field so the error message has already appeared when the page loads. i tried a few different ways. any suggestions would be greatly appreciated. thanks!
<?php
$email = $_POST["email"];
if(eregi('', $email))
{
$noEmail = 'error';
echo "<FONT COLOR=\"red\"> Please enter a valid email address! </FONT><br>";
}
?>
and
<?php
$email = $_POST["email"];
if(empty($email))
{
$noEmail = 'error';
echo "<FONT COLOR=\"red\"> Please enter a valid email address! </FONT><br>";
}
?>
and
<?php
$email = $_POST["email"];
if($email == '')
{
echo "<FONT COLOR=\"red\"> Please enter a valid email address! </FONT><br>";
$noEmail = 'error';
}
?>