Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Help with Email Validation
Old 10-03-2007, 08:01 PM Help with Email Validation
Experienced Talker

Posts: 40
Trades: 0
I've got a contact form that I would like to add email validation to. I would like to add the code shown HERE but don't know where it should be inserted in the page. The code I have so far is

Code:
<?
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
$_POST['firstname']=preg_replace("/(\015\012)|(\015)|(\012)/","&nbsp;<br />", $_POST['firstname']);if($_POST['firstname']=="" || $_POST['lastname']=="" || $_POST['email']=="" || $_POST['comments']=="" ){
$errors=1;
$error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
}
if($errors==1) $msg.="You did not enter one or more of the required fields.<br />Please go back and re-enter your contact request.";
else{
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$_SERVER['HTTP_HOST'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));
$message="
Firstname: ".$_POST['firstname']."
Lastname: ".$_POST['lastname']."
Email: ".$_POST['email']."
Address: ".$_POST['address']."
City: ".$_POST['city']."
State: ".$_POST['state']."
Zip: ".$_POST['zip']."
Phone: ".$_POST['phone']."
Interested: ".$_POST['interested']." 
Comments: ".$_POST['comments']."
";
mail("someone@somewhere.com","Stuff",$message,"From: Web Form");f
mail("$email","Thank you for contacting us", "Hi $firstname,\n
Thank you for contacting us!\n
We will respond to your enquiry as soon as possible.\n\n\n
Thanks.; 
$msg.="Thank you!<br />Your enquiry has been submitted and we will respond as soon as we can.";
}
?>
Any help with how to integrate email validation into that would be greatly appreciated. Of course, if someone knows of a better way to do email validation I'm game for that too.
Thanks.
Prometheus is online now
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-04-2007, 04:19 AM Re: Help with Email Validation
Galaxian's Avatar
Rich Powell

Posts: 842
Name: Rich Powell
Location: United Kingdom
Trades: 0
PHP Code:
<?

function valid_email($email){
if(
eregi("^[a-z1-9._-]{1,63}@[a-z1-9-]{2,63}\.{1}[a-z1-9]{2,4}(\.[a-z1-9]{2,4})*$"$email)) {
return 
true;
} else {
return 
false;
}
}

 
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
$_POST['firstname']=preg_replace("/(\015\012)|(\015)|(\012)/","&nbsp;<br />"$_POST['firstname']);if($_POST['firstname']=="" || $_POST['lastname']=="" || $_POST['email']=="" || $_POST['comments']=="" ){
$errors=1;
$error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
}
if(
$errors==1$msg.="You did not enter one or more of the required fields.<br />Please go back and re-enter your contact request.";
else{
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$_SERVER['HTTP_HOST'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));
$message="
Firstname: "
.$_POST['firstname']."
Lastname: "
.$_POST['lastname']."
Email: "
.$_POST['email']."
Address: "
.$_POST['address']."
City: "
.$_POST['city']."
State: "
.$_POST['state']."
Zip: "
.$_POST['zip']."
Phone: "
.$_POST['phone']."
Interested: "
.$_POST['interested'].
Comments: "
.$_POST['comments']."
"
;
if(
valid_email($_POST['email'])) {
mail("someone@somewhere.com","Stuff",$message,"From: Web Form");f
mail
("$email","Thank you for contacting us""Hi $firstname,\n
Thank you for contacting us!\n
We will respond to your enquiry as soon as possible.\n\n\n
Thanks.; 
$msg.="Thank you!<br />Your enquiry has been submitted and we will respond as soon as we can.";
} else {
$msg .= "The e-mail address was not valid!";
}

}
?>
but this is with my email validation, should be the same wiht jack daniels really
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please help get the new
Please login or register to view this content. Registration is FREE
forum started for Webmasters like you!

Galaxian is offline
Reply With Quote
View Public Profile Visit Galaxian's homepage!
 
Old 10-04-2007, 01:58 PM Re: Help with Email Validation
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
Darn you beat me to it Rich
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 10-11-2007, 10:30 PM Re: Help with Email Validation
Experienced Talker

Posts: 40
Trades: 0
Man that works perfectly, thanks alot Rich.
Prometheus is online now
Reply With Quote
View Public Profile
 
Reply     « Reply to Help with Email Validation
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.13295 seconds with 12 queries