Jump to content


Photo

Forms


  • Please log in to reply
3 replies to this topic

#1 Mike111

Mike111
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 17 July 2005 - 04:16 AM

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>&nbsp;</td>
<td><input type="submit" name="Submit" value="Submit">
<input type="reset" name="Reset" value="Reset"></td>
</tr>
</table>
</form>

#2 Rederick

Rederick
  • Members
  • Pip
  • Newbie
  • 6 posts
  • LocationNanaimo, BC Canada

Posted 17 July 2005 - 04:47 AM

Check out his php class.. it can do lots of crazy things

http://phpmailer.sourceforge.net/




#3 Mike111

Mike111
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 17 July 2005 - 05:12 AM

Check out his php class.. it can do lots of crazy things

http://phpmailer.sourceforge.net/

View Post


Website seems alright but I'm looking for something a little easier ;)

#4 jeremywesselman

jeremywesselman
  • Members
  • PipPipPip
  • Advanced Member
  • 154 posts
  • LocationIndependence, KY

Posted 17 July 2005 - 08:17 AM

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>&nbsp;</td>
                          <td><input type="submit" name="Submit" value="Submit">
                          <input type="reset" name="Reset" value="Reset"></td>
                        </tr>
                      </table>
          </form>

View Post


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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users