larissahn Posted June 13, 2009 Report Posted June 13, 2009 hi, I have this tell a friend php script. it works, it does send the email, but without any of the fields, like subject, friend's name, message. here is the code: <?php $site_name = "[url=http://www.utilaecology.org]www.utilaecology.org[/url]"; $subject = "Tell a friend"; $body = "Hello,\r\nYour friend $name ($email) has recommended that you see our website $site_name. He has also sent this message along with the recommendation:\r\n" . $message . "\r\n Thank you,\r\n-The webmaster"; if($_POST["send"] == "true") { $to = $_POST["to"]; $name = $_POST["name"]; $email = $_POST["email"]; $message = $_POST["message"]; if (($name == "") OR ($email == "") OR ($message == "")) { print (""); print ("One of the fields was left blank. Please put something in all fields. "); print (" "); email_form(); }elseif(ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $email)) { $recipient = $to; $subject = $the_subject; $additional_headers = ("From: $email\n"); if(mail($recipient, $subject, $body, $additional_headers)) { print (""); print ("Tell a friend script mailed your friend at $to about $site_name successfully. Thank you. "); print (" "); }else{ print (""); print ("Uh-Oh! Something went wrong with the script! Please try again. "); print (" "); $send = "false"; email_form(); } }else{ print (""); print ("That email address does not appear to be valid. Please try again. "); print (" "); $send = "false"; email_form(); } }else{ print (""); print (" Tell a friend"); print (" "); email_form(); } function email_form(){ global $subject_array, $recipient_array, $this_script, $PHP_SELF; print (""); print ("\n"); print (""); print ("To: \n"); print (""); print (" \n"); print (""); print ("Name: \n"); print (""); print (" \n"); print (""); print ("Your Email Address: \n"); print (""); print (" \n"); print (""); print ("Your Message: \n"); print (""); print (" \n"); print (""); print (""); print ("\n"); print (" \n"); print ("\n"); print (""); print ("\n"); print (""); print ("script by leapinglangoor"); print (""); print (""); } ?> Thanks! Quote
jbwebdesign Posted June 13, 2009 Report Posted June 13, 2009 i dont think that your $_POST[""]; needs double quotes, try using single quotes and see what happens Quote
jbwebdesign Posted June 13, 2009 Report Posted June 13, 2009 if that's not the problem, try changing the word METHOD on your form to lower case for example your form should be like this: echo ''; Quote
zamshed Posted June 17, 2009 Report Posted June 17, 2009 nice !!!! it's very helpful.... Zamshed http://www.zamshed.info/tech/ Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.