| | Just sends all form data to a specified email. Does anyone know a free script that does this? |
|
|
|
Step 1: Design and put a form on your webpage Step 2: Enter your correct email address and post_page link below (see inside script) Step 3: Upload the form file & the script file to your webspace N.B. Make sure the name of the script file is in exactly the same character case as specified in the FORM ACTION="scriptname" section. CODE <?php /************************************************************* Step 1: Create a form on your web-page with whatever fields are needed. It should use POST action to send the form input to this php script. Your form MUST contain two fields named "Name" & "Email" - the rest can be whatever you like. These two fields should be titled as I stated for the script to be able to extract the name and email of the user. See example here. <form action="sendformtoemail.php" method="post"> <table> <tr> ............ Form content goes here. Typical form would contain Name, Email & Comments ............ Fields & Submit and Clear Buttons. <td>Name:</td><td><input type="text" size="40" name="Name"></td> </tr> <tr>Email address:</td><td><input type="text" size="40" name="Email"></td> </tr> <tr> ............ Rest of fields </tr> </table> </form> **************************************************************/ /************************************************************* Step 2: Enter the email address to which the form will be mailed: **************************************************************/ $email_address = "put your email address here between quotes"; /************************************************************* The post_action varibale contain a link to which users are re-directed after successful submission of the form. If you don't want any other page to load leave it to "/" **************************************************************/ $post_page = "/"; /************************************************************* Step 3: Save this file as "sendformtoemail.php" upload it together with your webpage into the same directory as your Form page. **************************************************************/ // *********************************************************** // CRITICAL REGION // DO NOT EDIT THE CODE BELOW THIS UNLESS YOU KNOW WHAT YOU'RE DOING if ($_SERVER['REQUEST_METHOD'] != "POST") { exit; } // This loops through each line of the post and determines if any field has been left blank. // If so that field's contents are not included while ( list ( $field, $value ) = each ( $_POST ) ) { if ( ! ( empty ( $value ) ) ) { $notempty = 1; } $message = $message . "$field: $value\n\n"; } // If field is blank go back to referer URl, i.e. the form's page if ( $notempty !== 1 ) { header ( "location: $_SERVER[HTTP_REFERER]" ); exit; } // This line extracts the email address of the submitter from the form. This is why I emphasized // on being particular in naming the Name & Email text-fields. $Email = stripslashes ( $_POST['Email'] ); // Set subject of email, associated header and re-format message body $email_subject = "Feedback from my site"; $email_header = "From: " . $Email . "\n" . "Return-Path: " . $Email . "\n" . "Reply-To: " . $Email . "\n"; $message = stripslashes($message); // This is the step that actually uses the unix client named "mail" to mail the form to you. mail ( $email_address, $email_subject, $message, $email_header ); ?> <!-- END CRITICAL REGION *********************************************************** --> <!-- ONCE AGAIN YOU CAN EDIT THE PART BELOW THIS --> <!-- This part loads by default if you don't specify any after-post URL. This notifies the user that the form has been mailed properly. FEEL FREE TO EDIT THIS PART TO SUIT YOUR NEEDS. --> <html> <head> <title>You've successfully submitted the feedback</title> </head> <body> <font face="Tahoma"> Thank you <?php print stripslashes($_POST['Name']); ?><br> Your form has been sent.<br> <!-- Remember the $post_page variable that contained a link for the page to load after submission ? This is where it comes into action. If it is left "/" clicking this link will redirect you to you main index page. --> <a href="<?php print "$post_page"; ?>">Click here to continue</a> </font> </body> </html> See if this helps you. All the best
QUOTE // *********************************************************** // CRITICAL REGION // DO NOT EDIT THE CODE BELOW THIS UNLESS YOU KNOW WHAT YOU'RE DOING if ($_SERVER['REQUEST_METHOD'] != "POST") { exit; } This is not really necessary in my opinion because it doesn't really matter if the data is PUTted or POSTed. and you might want to lower the <?php - tag to under the html stuff. Or else you get syntax errors extra note : if you store something in a variable, use ' .... ' instead of " ... " since you only need "...." if you have regular expressions like /n in the data. using single quotes speeds the processing up a tiny bit since the parser does not have to look for regular expressions. You also might want to check if the sending succeeds, and use if (mail(bla,bla,bla,bla) == false ) { echo 'Sending failed'; } or something. Those were my suggestions, note that i'm not trying to out-smart you or anything Looking at your code, i can see that you have good coding-etiquette, nice comments and stuff. I hardly comment my code :blush:. So I gotta learn that one day too
Well now, since the other was so rudely closed... (ironic as it was a moderator who initially replyed to my post... and the topic was left open... weird. And my appologies for digging up an close-to-month old topic... got yelled at for starting a new one...)
If I understand this correctly, under this line: CODE $post_page = "/"; if the "/" is changed to a url, the url will be displayed after submission instead of: <html> <head> <title>You've successfully submitted the feedback</title> </head> <body> <font face="Tahoma"> Thank you <?php print stripslashes($_POST['Name']); ?><br> Your form has been sent.<br> <!-- Remember the $post_page variable that contained a link for the page to load after submission ? This is where it comes into action. If it is left "/" clicking this link will redirect you to you main index page. --> <a href="<?php print "$post_page"; ?>">Click here to continue</a> </font> </body> </html> Or would I have to edit the html at the end of the code in order for it to display the "thank you" page I would like the users to see? Comments back from m^e on this would be appreciated, as it is their code...
You can freely edit the HTML at the end of the code - this HTML gives shape to your Thank You page.. so you can change it to whatever you like..
The $post_page="/" --> This variable contains the link, that is loaded AFTER the Thank You page. If you want a different page to load after Thank You, ONLY then you should include the link here. If you leave it to simply "/" - as you can see from this code CODE <a href="<?php print "$post_page"; ?>">Click here to continue</a> // This gets parsed as: <a href="/">Click here to continue</a> which means, you're being taken back to the top-level or index page of your site. Hope this will clear it up. P.S. Also when quoting some sort of code in your posts, use the CODE tag to enclose it - that makes easier reading. Am modifying your post to demonstrate it.
Think I have it now. On another note, would script be able to be added to this file or a seperate sript be posted that would send an auto-reply email to the user's email address posted?
Go to www.Javascriptkit.com you can find tuns of scripts that do it. (Sorry if I'm not sopposed to include the links but I don't want to plagerize).
QUOTE (ironic as it was a moderator who initially replyed to my post... and the topic was left open... Are you talking about microscopic here? M^E give you the link to this topic a few minutes before I could do and he didn't think it was necessary to close it. I thought that it might be better to close it so nobody else is going to reply here, and if they had comments they would reply here. So i did (you still with me and about QUOTE close-to-month old topic That doesn't matter because knowledge = knowledge, even if its almost an year old. Maybe it might feel silly to reply to something a month old, but if you have a question and post it it there, it will show up on the last post thingy on the bottom and people will read it and reply to it. It's not so that noones going to reply because the topics old Who cares if the topic was started a month ago?
Many forums I've been to in the past view the digging up of old topics to be spammy, as a multitude of people will just go thread by thread and reply to everything, even though it has no current relevence.
In any event, I'll be testing everything out and seeing if it all works the way I'm hoping it will sometime either today or tommorow. Thanks for the help up to now...
Similar Topics
Keywords : form, mail, php, php, send, form, email
(4) Hello fellow astahostians! I made an email form for my site, where I want customers to be able to (5) While the mail() function of php is all bout simplicity, it lacks the otherwise necessary (8) Can anyone here tell me how to send mail through SMTP server with php /mellow.gif" (4) I just coded this e-mail list, it works well for entering data into database, but if user leaves Can't find a decent tutorial! (5) I read the one mail() tutorial that was posted in the tutorial section and to my horror found that Possibility of sending a newsletter (12) Task : To send an email to a list of email addresses stored in a database Premise : Page is check for correct address and syntax (2) Hey , this tutorial will tell you a very simple way to check if email addresses entered are with the Refusing wrong info in a form... (10) Hello there! I'm learning php and MySQL these days... Here I've got a little script I'm email your self with a form from vistors (3) hey plzzzz all exceperinced pepole in php can you describe step by step how to make a beutifull form (2) Repeat post. Credits reduced by 5 days. Learn to USE THE SEARCH BUTTON before you make such posts. (4) I'm trying to use the mail() function in a script. But it doesnt work. It keeps returning false. need help (2) I have a problem with send e-mail form! First it was designed only for name,email,subject and (4) I am programming on a web site's contact form page, How can I mail the filled in information of Looking for form, mail, php, php, send, form, email
|
![]() Form Mail Php - Use Php To Send Form Through Email |
| ADD REPLY / Got an Opinion! | a humble request :-) | RAPID SEARCH! | Free Hosting | [X] |
|
Express your Opinions, Thoughts or Contribute your information that might help someone here. Ask your Doubts & Queries to get answers.. "Together, We enlight each other!" |
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP. | 500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE |
|