emory7
asked on
Vailidate E-mail Field
Hi All,
I need to validate the e-mail field on a simple subscribe request form. I want a pop-up warning the user to enter a valid e-mail address if, say, the "@" character is not entered. I appreciate your help.
Thanks,
Emory
Script in mail.php:
<?php
$to="myemail@mydomain.com" ;
$message="$email requests to be added to the mailing list.";
if(mail($to,"Subscribe Request",$message,"From: $email\n")) {
echo "Thanks for subscribing to the mailing list.";
} else {
echo "There was a problem sending the mail. Please check that you filled in the form correctly.";
}
?>
form:
<table id="table4" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="125" height="37">
<tr>
<td width="126" height="1" valign="top" bgcolor="#99CC00">
<p align="center">
<h4 align="center"><span lang="en-us">Subscribe</sp an>
</td>
</h4>
</tr>
<tr>
<td width="126" height="85" valign="top" align="center">
<form action="mail.php" method="post">
<p><span lang="en-us">Enter your e-mail to receive news and updates </span>
<input type="text" name = "email" size="12" value="" <input type="submit" value="Submit"></p>
</form></td>
</tr>
</table>
I need to validate the e-mail field on a simple subscribe request form. I want a pop-up warning the user to enter a valid e-mail address if, say, the "@" character is not entered. I appreciate your help.
Thanks,
Emory
Script in mail.php:
<?php
$to="myemail@mydomain.com"
$message="$email requests to be added to the mailing list.";
if(mail($to,"Subscribe Request",$message,"From: $email\n")) {
echo "Thanks for subscribing to the mailing list.";
} else {
echo "There was a problem sending the mail. Please check that you filled in the form correctly.";
}
?>
form:
<table id="table4" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="125" height="37">
<tr>
<td width="126" height="1" valign="top" bgcolor="#99CC00">
<p align="center">
<h4 align="center"><span lang="en-us">Subscribe</sp
</td>
</h4>
</tr>
<tr>
<td width="126" height="85" valign="top" align="center">
<form action="mail.php" method="post">
<p><span lang="en-us">Enter your e-mail to receive news and updates </span>
<input type="text" name = "email" size="12" value="" <input type="submit" value="Submit"></p>
</form></td>
</tr>
</table>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER