Mike111 Posted July 17, 2005 Share Posted July 17, 2005 I am wondering how to have form results submit to my e-mail. Below is my code, if anyone could tell me where to insert what I need, I would definitely appreciate it! <form action="" method="post" name="form1"> <table width="443" border="0"> <tr> <td width="131"><span class="style14">Your Name: </span></td> <td width="246"><span class="style14"> <input type="text" name="textfield"> </span></td> </tr> <tr> <td><span class="style14">Recipient Name: </span></td> <td><span class="style14"> <input type="text" name="textfield"> </span></td> </tr> <tr> <td><span class="style14">Your E-mail:</span></td> <td><span class="style14"> <input type="text" name="textfield"> </span></td> </tr> <tr> <td><span class="style14">Subject:</span></td> <td><span class="style14"> <input type="text" name="textfield"> </span></td> </tr> <tr> <td><span class="style14">Message:</span></td> <td><p class="style14"> <textarea name="textarea"></textarea> </p> </td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Submit"> <input type="reset" name="Reset" value="Reset"></td> </tr> </table> </form> Quote Link to comment https://forums.phpfreaks.com/topic/2405-forms/ Share on other sites More sharing options...
Rederick Posted July 17, 2005 Share Posted July 17, 2005 Check out his php class.. it can do lots of crazy things http://phpmailer.sourceforge.net/ Quote Link to comment https://forums.phpfreaks.com/topic/2405-forms/#findComment-7910 Share on other sites More sharing options...
Mike111 Posted July 17, 2005 Author Share Posted July 17, 2005 Check out his php class.. it can do lots of crazy things http://phpmailer.sourceforge.net/ 254134[/snapback] Website seems alright but I'm looking for something a little easier Quote Link to comment https://forums.phpfreaks.com/topic/2405-forms/#findComment-7912 Share on other sites More sharing options...
jeremywesselman Posted July 17, 2005 Share Posted July 17, 2005 I am wondering how to have form results submit to my e-mail. Below is my code, if anyone could tell me where to insert what I need, I would definitely appreciate it! <form action="" method="post" name="form1"> <table width="443" border="0"> <tr> <td width="131"><span class="style14">Your Name: </span></td> <td width="246"><span class="style14"> <input type="text" name="textfield"> </span></td> </tr> <tr> <td><span class="style14">Recipient Name: </span></td> <td><span class="style14"> <input type="text" name="textfield"> </span></td> </tr> <tr> <td><span class="style14">Your E-mail:</span></td> <td><span class="style14"> <input type="text" name="textfield"> </span></td> </tr> <tr> <td><span class="style14">Subject:</span></td> <td><span class="style14"> <input type="text" name="textfield"> </span></td> </tr> <tr> <td><span class="style14">Message:</span></td> <td><p class="style14"> <textarea name="textarea"></textarea> </p> </td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Submit"> <input type="reset" name="Reset" value="Reset"></td> </tr> </table> </form> 254127[/snapback] First, you need to change the "name" property of your textboxes to something that describes what is in them. So, if the first textbox is "name", you will need to change "name = 'textfield'" to "name='name'". Do this for the rest of the form. Then you are going to start off by setting up the process part of the page. [!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--][span style=\"color:#0000BB\"]<?php [/span][span style=\"color:#007700\"]if(isset([/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'Submit\'[/span][span style=\"color:#007700\"]])) { [/span][span style=\"color:#FF8000\"]//Enter form processing here [/span][span style=\"color:#007700\"]} else { [/span][span style=\"color:#FF8000\"]//Your form could go here so it doesn\'t show up when you submit it. [/span][span style=\"color:#007700\"]} [/span][span style=\"color:#0000BB\"]?>[/span] [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] So after this, we will need to get all the values of the textboxes on your form. [!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--][span style=\"color:#0000BB\"]<?php [/span][span style=\"color:#007700\"]if(isset([/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'Submit\'[/span][span style=\"color:#007700\"]])) { [/span][span style=\"color:#0000BB\"]$name [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'name\'[/span][span style=\"color:#007700\"]]; [/span][span style=\"color:#0000BB\"]$email [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'email\'[/span][span style=\"color:#007700\"]]; [/span][span style=\"color:#FF8000\"]//etc... You get the point. [/span][span style=\"color:#007700\"]} else { [/span][span style=\"color:#FF8000\"]//form [/span][span style=\"color:#007700\"]} [/span][span style=\"color:#0000BB\"]?>[/span] [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] After you collect all of your data, go ahead and do any error checking you want on it. (Check if it is empty, correct, etc). Then comes the mail part. [!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--][span style=\"color:#0000BB\"]<?php [/span][span style=\"color:#007700\"]... [/span][span style=\"color:#FF8000\"]//the mail function [/span][span style=\"color:#0000BB\"]$to [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#FF8000\"]//The person you are sending it to [/span][span style=\"color:#0000BB\"]$subject [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#FF8000\"]//The subject of the email [/span][span style=\"color:#0000BB\"]$message [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#FF8000\"]//The message you want to appear in the body of the email [/span][span style=\"color:#0000BB\"]$email [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\"\" [/span][span style=\"color:#FF8000\"]//The person email address who is sending email [/span][span style=\"color:#0000BB\"]mail[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$to[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$subject[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$message[/span][span style=\"color:#007700\"], [/span][span style=\"color:#DD0000\"]\"FROM: $email\"[/span][span style=\"color:#007700\"]); ... [/span][span style=\"color:#0000BB\"]?>[/span] [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] The mail part goes in the processing part of the script. Jeremy Quote Link to comment https://forums.phpfreaks.com/topic/2405-forms/#findComment-7916 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.