ok, so my problem is that when typing the email address in for an email list and simply hittin enter instead of clicking on submit the page is refreshing and not posting any data at all, but its not giving an error message either: so the user has no clue that nothing has gone wrong. i have error handling that works as long as you click submit, but i need it to work when you hit enter too.
here is the code:
----------------------------------------------------------
<?php //script 1.3 index.php email
//checks if submit button has been used
if (isset($_POST['submit'])) {
//handle the form
//validates email and stripslashes
if (!eregi ("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$",stripslashes(trim($_POST['email'])))) {
$problem = TRUE;
$errorMessage .= '<p>Please Enter A Valid Email Address.</p>';
}
//check if anything went wrong
if (!$problem) { //nothign went wrong
$message=$email . ',';//concatenates string for text file
echo "Your email address, $message has been added.";
$fp=fopen("./emailList/emailLog.log","a+");// read and write capability for emailLog
fwrite($fp,$message);//writes file
fclose($fp);
} else {
echo "<center><h4><font color=#FF0000>\n The email address,$email, is not valid.\n Please go back to re-enter your information</ font></ h4></ center>";
} else {
//displays form
?>
<form name="signup" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<legend>Enter Your Email Address Below</legend>
<p><b>Email Address:</b>
<input type="text" name="email"
value="<?php if(isset($_POST['name'])) echo $_POST['name']; ?>" />
<input type="submit" name="submit" value="Submit" class="fbutton" />
</form><!-- end of form -->
<?php
} //closes conditional statement
?>
---------------------------------------------------------------------------------
any help or suggestions would be great, i've been hitting my head against this, and i'm sure its something stupid i've absent mindedly forgotten. thanks
here is the code:
----------------------------------------------------------
<?php //script 1.3 index.php email
//checks if submit button has been used
if (isset($_POST['submit'])) {
//handle the form
//validates email and stripslashes
if (!eregi ("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$",stripslashes(trim($_POST['email'])))) {
$problem = TRUE;
$errorMessage .= '<p>Please Enter A Valid Email Address.</p>';
}
//check if anything went wrong
if (!$problem) { //nothign went wrong
$message=$email . ',';//concatenates string for text file
echo "Your email address, $message has been added.";
$fp=fopen("./emailList/emailLog.log","a+");// read and write capability for emailLog
fwrite($fp,$message);//writes file
fclose($fp);
} else {
echo "<center><h4><font color=#FF0000>\n The email address,$email, is not valid.\n Please go back to re-enter your information</ font></ h4></ center>";
} else {
//displays form
?>
<form name="signup" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<legend>Enter Your Email Address Below</legend>
<p><b>Email Address:</b>
<input type="text" name="email"
value="<?php if(isset($_POST['name'])) echo $_POST['name']; ?>" />
<input type="submit" name="submit" value="Submit" class="fbutton" />
</form><!-- end of form -->
<?php
} //closes conditional statement
?>
---------------------------------------------------------------------------------
any help or suggestions would be great, i've been hitting my head against this, and i'm sure its something stupid i've absent mindedly forgotten. thanks