Aloha Posted September 16, 2013 Share Posted September 16, 2013 My name is Sarah. I am new to php. I found a sample php script I'd like to use which sends user-entered data from an HTML form to another page, which gets processed there with php. But I don't know how to also get the form results emailed to me. Here's what I mean:Here's the HTML Form:<html><body><h4>Tizag Art Supply Order Form</h4><form action="process.php" method="post"><select name="item"><option>Paint</option><option>Brushes</option><option>Erasers</option></select>Quantity: <input name="quantity" type="text" /><input type="submit" /></form></body></html>Here's the php processing the form:<html><body><?php$quantity = $_POST['quantity'];$item = $_POST['item'];echo "You ordered ". $quantity . " " . $item . ".<br />";echo "Thank you for ordering from Tizag Art Supplies!";?></body></html>But I would also like to have the user entered data emailed to me. Can anyone help or show me how to do it?Thank you, Quote Link to comment Share on other sites More sharing options...
fastsol Posted September 16, 2013 Share Posted September 16, 2013 You're missing a bunch of code to make this anything that someone would actually want to fill out. You don't even have anything that gathers the persons name, email, phone, etc. You don't have any clue who is even filling out the form and wants stuff. You're also wide open for XSS attacks, not that a beginner would be expected to know that kind of thing. Check out this tutorial series to get you started. http://www.youtube.com/playlist?list=PLF07A207A932D3997 Quote Link to comment Share on other sites More sharing options...
Aloha Posted September 16, 2013 Author Share Posted September 16, 2013 ok thank you. Quote Link to comment Share on other sites More sharing options...
Manan Posted September 18, 2013 Share Posted September 18, 2013 Try this for your mail requiremnt <?php $to = 'nobody@example.com'; //set your email id $subject = 'the subject'; $message = 'hello'; $headers = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); ?> Quote Link to comment Share on other sites More sharing options...
priyankagound Posted September 18, 2013 Share Posted September 18, 2013 (edited) For mailing you must first gather the person information and then filling out the form and what order they want to do. Below is the small example for email which may help you. <?php $action=$_REQUEST['action']; if ($action=="") /* display the contact form */ { ?> <form action="" method="POST" enctype="multipart/form-data"> <input type="hidden" name="action" value="submit"> Your name:<br> <input name="name" type="text" value="" size="30"/><br> Your email:<br> <input name="email" type="text" value="" size="30"/><br> Your message:<br> <textarea name="message" rows="7" cols="30"></textarea><br> <input type="submit" value="Send email"/> </form> <?php } else /* send the submitted data */ { $name=$_REQUEST['name']; $email=$_REQUEST['email']; $message=$_REQUEST['message']; if (($name=="")||($email=="")||($message=="")) { echo "All fields are required, please fill <a href=\"\">the form</a> again."; } else{ $from="From: $name<$email>\r\nReturn-path: $email"; $subject="Message sent using your contact form"; mail("youremail@yoursite.com", $subject, $message, $from); echo "Email sent!"; } } ?> Edited September 18, 2013 by priyankagound Quote Link to comment Share on other sites More sharing options...
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.