|
|
|
|
![]() ![]() |
Mar 25 2005, 11:54 PM
Post
#1
|
|
|
Member [ Level 2 ] Group: Members Posts: 69 Joined: 4-February 05 Member No.: 2,509 |
Just sends all form data to a specified email. Does anyone know a free script that does this?
This post has been edited by microscopic^earthling: Apr 19 2005, 10:03 AM |
|
|
|
Mar 26 2005, 06:15 AM
Post
#2
|
|
|
PsYcheDeLiC dR3aMeR Group: Admin Posts: 2,242 Joined: 29-January 05 From: Nakorn Chaisri, Thailand Member No.: 2,411 myCENTs:84.36 |
I'm not good at JavaScript - you might be able to find lots of them at HotScripts.Com or javascript.internet.com - but here's an easy alternative. I've got a ready-to-run PHP Script that does exactly the same thing. Take a look at it - the comments inside the script will guide you through what to do/what not to do. Make sure you read all the comments properly. Otherwise this is an easy 3 step process:
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 |
|
|
|
Mar 26 2005, 06:41 PM
Post
#3
|
|
|
Pretty please? Group: Members Posts: 733 Joined: 28-November 04 From: Holland Member No.: 1,552 |
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 |
|
|
|
Apr 17 2005, 12:09 PM
Post
#4
|
|
|
Member [ Level 2 ] Group: Members Posts: 59 Joined: 16-April 05 Member No.: 4,039 |
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... |
|
|
|
Apr 17 2005, 01:03 PM
Post
#5
|
|
|
PsYcheDeLiC dR3aMeR Group: Admin Posts: 2,242 Joined: 29-January 05 From: Nakorn Chaisri, Thailand Member No.: 2,411 myCENTs:84.36 |
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. |
|
|
|
Apr 17 2005, 02:03 PM
Post
#6
|
|
|
Member [ Level 2 ] Group: Members Posts: 59 Joined: 16-April 05 Member No.: 4,039 |
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?
|
|
|
|
Apr 17 2005, 02:29 PM
Post
#7
|
|
|
Uber-Pro [ Level 99 ] Group: Members Posts: 419 Joined: 13-April 05 From: USA-Wisconsin Member No.: 3,957 |
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).
|
|
|
|
Apr 17 2005, 02:39 PM
Post
#8
|
|
|
Pretty please? Group: Members Posts: 733 Joined: 28-November 04 From: Holland Member No.: 1,552 |
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? |
|
|
|
Apr 19 2005, 07:45 PM
Post
#9
|
|
|
Member [ Level 2 ] Group: Members Posts: 59 Joined: 16-April 05 Member No.: 4,039 |
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
|
Lo-Fi Version | Time is now: 2nd December 2008 - 09:27 PM |