robmo Posted August 3, 2010 Share Posted August 3, 2010 Hi, I have an HTML form created using Dreamweaver and now I need a script to handle the form processing. Basically what I need is for the form data received from the webpage to be organized in an email and then sent to me. I would also like to display a thank you message in the browser so the user knows it was received. I was planning to do this using CGI but a colleague suggested that CGI is old school and nowadays a developer would use PHP for this task. Is PHP the right solution for this project? The examples I have found so far always include the HTML for the form and the script needed to handle it in one file. In my case, I have an HTML form already in place and need it to work with a script to perform the email function. I know I need to set "Action=" on my webpage to point to the PHP script but what would the code look like if no HTML is needed? I hope this makes sense... Thanks for your help! Rob Link to comment https://forums.phpfreaks.com/topic/209702-php-web-forms-handling/ Share on other sites More sharing options...
xcoderx Posted August 3, 2010 Share Posted August 3, 2010 where is ur form? btw there are thousads available on google for such purpose i guess. :-) Link to comment https://forums.phpfreaks.com/topic/209702-php-web-forms-handling/#findComment-1094737 Share on other sites More sharing options...
robmo Posted August 3, 2010 Author Share Posted August 3, 2010 My form is located at the link below. It doesn't do anything yet as there is no code available to process the form. I have spent some time looking for examples and I see that there are many but of course, they don't meet my needs and require editing. My main question is if PHP is the solution by today's standards. http://www.tallfirshoa.com/adform.htm Link to comment https://forums.phpfreaks.com/topic/209702-php-web-forms-handling/#findComment-1094745 Share on other sites More sharing options...
xcoderx Posted August 3, 2010 Share Posted August 3, 2010 <?php if(isset($_POST['submit'])) { $to = "[email protected]"; $subject = "Your subject"; $fname = $_POST['fname']; $lname = $_POST['lname']; $email = $_POST['email']; $displayemail = $_POST['displayemail']; $phone = $_POST['phone']; $category = $_POST['category']; $description = $_POST['description']; $headers = "From: $email \r\n Reply-To: $email"; $body = "From: $fname $lname\n E-mail: $email\n Display Email on website: $displayemail\n Phone: $phone\n Category: $category\n Description:\n $description"; echo "Dear $fname $lname, <br/> Your Information<br/> E-mail: $email, <br/> Display Email on website: $displayemail, <br/>Phone: $phone, <br/>Categoty: $category, <br/>Description: $description <br/><br/> has been submitted successfully to us!"; mail($to, $subject, $body, $headers); } else { echo "Error!"; } ?> Link to comment https://forums.phpfreaks.com/topic/209702-php-web-forms-handling/#findComment-1094800 Share on other sites More sharing options...
robmo Posted August 3, 2010 Author Share Posted August 3, 2010 Well, I wasn't really asking you to code this for me but thank you so much! I can easily see now how this is done. I just found it very confusing with the HTML intermixed with the PHP code. I'm obviously not a PHP developer but I do write code in other languages. Thanks again! Rob Link to comment https://forums.phpfreaks.com/topic/209702-php-web-forms-handling/#findComment-1094811 Share on other sites More sharing options...
xcoderx Posted August 4, 2010 Share Posted August 4, 2010 oh ok, i thought mebbe u were asking for one anyways u got to validate the above codes if u know how to? Link to comment https://forums.phpfreaks.com/topic/209702-php-web-forms-handling/#findComment-1095215 Share on other sites More sharing options...
robmo Posted August 4, 2010 Author Share Posted August 4, 2010 xcoderx, I think I can take it from here. Just this snippet alone has helped a lot in understanding how use PHP in this application. Thanks again! Rob Link to comment https://forums.phpfreaks.com/topic/209702-php-web-forms-handling/#findComment-1095231 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.