Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,531 members, 7,819,912 topics. Date: Tuesday, 07 May 2024 at 06:26 AM

Tranfering Filled Forms Content To My E.mail (code Please) - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Tranfering Filled Forms Content To My E.mail (code Please) (737 Views)

Please Review This Site And Suggest Css Code Please / Soure Code.please Read / Gsm Short Code; Please Help: (2) (3) (4)

(1) (Reply)

Tranfering Filled Forms Content To My E.mail (code Please) by ooe1: 2:51pm On Nov 20, 2007
Please coders in th house I am new to programming. I want to know the code to use to transfer the form on my web site to my e.mail inbox when visitors fill them. Thanks.
Re: Tranfering Filled Forms Content To My E.mail (code Please) by my2cents(m): 3:47pm On Nov 20, 2007
Assuming your language of choice is PHP, here is a script i use a lot. I hope this helps:


error_reporting(0);
$recipient = 'ssss@yahoo.com';
$subject = $_POST['subject'];
$from = $_POST['full_name'];
$emailaddress = $_POST['email_addr'];
$comments = $_POST['comments'];

$subject = "Email from o_oe - " . stripslashes($subject);
$from = stripslashes($from);
$emailaddress = stripslashes($emailaddress);
$comments = stripslashes($comments);

if(!$subject || !$from || !$emailaddress || !$comments) {
echo '<p>You have not faithfully filled out this form. Please go back and try again.</p>';
exit;
}

$sender = "From: ".$emailaddress."\n\r";
$msg = "Message from: $from\n".$comments;
if (mail($recipient, $subject, $msg, $sender))
echo nl2br("<strong>Printed below is the message you sent and which we will receive.:</strong>

<strong>To:</strong> $recipient
<strong>Subject:</strong> $subject
$msg
$sender"wink;
else
echo "Message failed to send";

The section:
if(!$subject || !$from || !$emailaddress || !$comments) {
echo '<p>You have not faithfully filled out this form. Please go back and try again.</p>';
exit;
}

is my backup plan to verify that all required fields are not left blank, on the backend, in the event that a user has javascript turned off.

It may not be the best code in the world, but hey, it works cool

(1) (Reply)

Guide To Free Software And Web Apps / Greaat New For Webmaster That Uses Google Adsense(adsense Only) / Against All Odds

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 8
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.