vietboy505 Posted March 3, 2006 Share Posted March 3, 2006 I need help on the e-mail form to work, can any one help me?I want the form to check if everything is inputs correct such as an valid e-mail.[code]<?phpfunction determineEmail($Purpose){ if($Purpose == "General") { $mailTo="Name1 <[email protected]>, Name2 <[email protected]>"; } elseif($Purpose == "Customer") { $mailTo="Name2 <[email protected]>, Name3 <[email protected]>"; } else { //proably won't be in here $mailTo="[email protected]"; }}if(!preg_match("/^([0-9a-zA-Z]([-.w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-w]*[0-9a-zA-Z].)+[a-zA-Z]{2,9})$/",$_POST["Email"])) {//email address is invaliddie("Invalid Email");}if(!empty($message)){ // only send if the form has been filled out. $mailHeaders="From : $Name [$Email]"; $mailSubject="$Purpose from $Name"; $mailBody="Sent by $Name ($Email) on " . date('M j,Y h:i:s') . " \n\n"; $mailBody.="Message : \n\n $message"; mail($mailTo, $mailSubject, $mailBody, $mailHeaders); echo "<b>Your email has been sent!</b><br>";}echo('<form name="email_form" method="post"><input type="hidden" name="require" value="Name,Email,Purpose,Comments"><table><tr> <td align="right">Name:</td> <td><input name="Name" size="25"></td></tr><tr> <td align="right">E-mail:</td> <td><input name="Email" size="25"></td></tr><tr> <td align="right">Purpose:</td> <td><select name="Purpose"> <option value="General">General <option value="Customer">Customer </select> </td></tr><tr> <td align="right">Comments:</td> <td><textarea name="Comments" rows="10" cols="40"></textarea> </td></tr><tr> <td colspan="2" align="center"><input type="submit" value="Submit" name="email_form"> <input type="reset" value="Reset" name="reset"></td></tr></table></form>');?>[/code] Link to comment https://forums.phpfreaks.com/topic/3977-e-mail-validation/ Share on other sites More sharing options...
play_ Posted March 3, 2006 Share Posted March 3, 2006 Are you getting any errors? if so, show us which. Link to comment https://forums.phpfreaks.com/topic/3977-e-mail-validation/#findComment-13816 Share on other sites More sharing options...
vietboy505 Posted March 3, 2006 Author Share Posted March 3, 2006 I only see "Invalid Email". Link to comment https://forums.phpfreaks.com/topic/3977-e-mail-validation/#findComment-13820 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.