addtrain Posted August 10, 2007 Share Posted August 10, 2007 ok.... i want to make an input box email me with whatever the person typed into the input. how do i do this? Link to comment https://forums.phpfreaks.com/topic/64239-solved-small-problem-with-my-input-box/ Share on other sites More sharing options...
stervyatnik Posted August 10, 2007 Share Posted August 10, 2007 I use FormMail.php, and it works GREAT! Here's a sample form, with the appropriate action: [pre] <form name="form1" method="post" action="formmail.php"> <input name="recipient" type="hidden" value="[email protected]"> <input name="subject" type="hidden" value="Type your subject here"> <p>Name</p> <input name="name" type="text" id="name"> <p>Email</p> <input name="email" type="text" id="email"> <p>Comment/Question:</p> <textarea name="comment" rows="6" id="comment"></textarea> </form> [/pre] Note that it references "formmail.php" in the action. You just have to load formmail into the same directory as your form (or you can reference a path to it, of course), and change a couple of parameters in the formmail.php file, and it automatically processes ALL your form info. In formmail.php, you have to set the referrers - so people can't really use your formmail.php script for spamming. Then you're ready to go. Here's a link to formmail.php: http://www.dtheatre.com/scripts/formmail.php Hope that helps! Dan sends... Link to comment https://forums.phpfreaks.com/topic/64239-solved-small-problem-with-my-input-box/#findComment-320259 Share on other sites More sharing options...
Fadion Posted August 10, 2007 Share Posted August 10, 2007 U can use the builtin php email gateway. Use a code like this: <form id="form1" name="form1" method="post" action=""> <input type="text" name="email" id="email" /> <input type="submit" name="button" id="button" value="Submit" /> </form> <?php if(array_key_exists('data', $_POST)){ $data = $_POST['data']; $to = "[email protected]"; $subject = "Email from your site"; $message = "This information has been submited to your website: \n\n"; $message .= $data; $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\n"; $headers .= "To: Your Name <$to>\n"; $headers .= "From: Your Site <[email protected]>\n"; if(@mail($to, $subject, $message, $headers)){ echo "Your data was sent succesfully"; } else{ echo "There was a problem sending your email. Plese retry later"; } } ?> If the post data is submited, the script will send u an email with that data. It involves simple error handling for the mail() function to determine if the email was sent. Replace the $to with your email and FROM in $headers with the sender email. Hope it helps. Link to comment https://forums.phpfreaks.com/topic/64239-solved-small-problem-with-my-input-box/#findComment-320423 Share on other sites More sharing options...
addtrain Posted August 11, 2007 Author Share Posted August 11, 2007 hi all and thanks everyone else has been pretty cold towards me... yes i am very unexpeirenced, but i am still learning and i came here to learn. both replys work great. this topic is SOLVED!!! Link to comment https://forums.phpfreaks.com/topic/64239-solved-small-problem-with-my-input-box/#findComment-320837 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.