php question

Forum
Last Post
Threads / Messages

maximillion

Member
Member
Joined
Jun 6, 2011
Messages
67
Points
0
Location
Rhode Island
Mysidian Dollar
5,082
what i am looking to accomplish:

i have a simple form where a user enters their email and clicks submit..

what i need is 1 php file that sends me an email containing their email address.. it doesn't need to give a thank you message or anything, just clear the box after submitting.

it can have like a popup box saying something like "Thank you, your email address has been submitted."
 
Last edited:
Code:
<?php 
 $theiremail = $_REQUEST['email']; 
 $to = 'youremail@live.com';
 $fields = array(); 
 $fields{"email"} = "Email"; 
 $body = "\n\n"; foreach($fields as $a => $b){ 	$body .= sprintf("%20s: %

s\n",$b,$_REQUEST[$a]); } 
 
 $headers2 = "From: $theiremail"; 
 $subject2 = "Someone contacted you"; 
 $autoreply = "".$theiremail."";
 
 if($theiremail == '') {print "You have not entered an email, please go 

back and try again";} 
 else { 
 
 $send = mail($to, $subject2, $autoreply, $headers2); 
 if($send) 
 {header( "Location: http://www.site.com/thanks" );} 
 else 
 {print "We encountered an error, please notify 

webmaster@YourCompany.com"; } 
 }
?>
I got the code from http://php.about.com/od/phpapplications/ss/form_mail_3.htm and I altered it.
 
Last edited:
No, I tested it before I posted it...
Do you have a field that has the name of 'email' (caps matters). Did you add your email in the $to = youremail ? Is there any spaces there or typos? A common reason is because you didnt check the spam mail in your email. It goes to spam because most subdomain hosts arent trusted by email sites.
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,122
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Top