Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Website Design Forum


You are currently viewing our Website Design Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Process a form and email it
Old 12-17-2004, 05:35 PM Process a form and email it
Junior Talker

Posts: 136
Trades: 0
Sure you can use a cgi script to process a form that your user submits and have it emaail it to you, but why not use PHP? I understand php much better, and the code is fairly simple.

form.html (the user submitted form)
Code:
<form name="form1" method="post" action="processmail.php">
	 <input type=hidden name="required" value="email,text">
      <table width="531" border="0" cellpadding="5">
        <tr>
          <td width="147" align="left" valign="middle">Name</td>
          <td width="358"><input name="name" type="text" id="name" size="24"></td>
        </tr>
        <tr>
          <td align="left" valign="middle">Email Address <span class="title">*</span> </td>
          <td><input name="email" type="text" id="email" size="24"></td>
        </tr>
        <tr>
          <td align="left" valign="middle">Subject</td>
          <td><input name="subject" type="text" id="subject" size="24"></td>
        </tr>
        <tr>
          <td align="left" valign="middle">Message <span class="title">*</span> </td>
          <td><textarea name="text" cols="50" rows="6" id="text"></textarea></td>
        </tr>
        <tr>
          <td align="left" valign="middle"><span class="title">*</span> = required </td>
          <td><input type="submit" name="Submit" value="Submit">&nbsp;&nbsp;&nbsp;<input type="reset" name="Reset" value="Reset"></td>
        </tr>
      </table>
    </form>
Just save that as whatever name you want for now, you can modify it later.


processmail.php (the script)
Code:
<?php
@extract($_POST);
$name = stripslashes($name);
$email = stripslashes($email);
$subject = stripslashes($subject);
$text = stripslashes($text);
mail('email@domain.com',$subject,$text,"From: $name <$email>");
?>
Simple code, just make sure that you have a variable for everything you are posting to this. Extra variables you will want to put in the text area, like this:
Code:
mail('email@domain.com',$subject,"$text $extra_variable extra_variable","From: $name <$email>");
If you want something to display after the user submits the data (like a page that says the data was submitted successfully), then just add your HTML code in the process.php file after the code I gave you above.


Now I may have not explained it as best as I could have.. but I have een using this code for a while so I am not that good at thinking how it was when I didn't know it. If you need help setting this up on your site, just reply here, send me a private message, or contact me via one of the instant messenger programs in my profile.



Also, if you want to see how the form looks, or how it works, I have this running on my site at http://www.dewknight.com/contact.php. But please don't submit it multiple times, it actually does send me an email when you submit it.
microski is offline
Reply With Quote
View Public Profile Visit microski's homepage!
 
 
Register now for full access!
Old 12-17-2004, 05:37 PM Re: Process a form and email it
Banned

Posts: 0
Trades: 0
thanks for the tut.
wirlwind1 is offline
Reply With Quote
View Public Profile
 
Old 12-17-2004, 05:38 PM Re: Process a form and email it
Junior Talker

Posts: 136
Trades: 0
I'll work on throwing up a few other tutorials for stuff that I have implemented on my site.. like a simple news system and such.
microski is offline
Reply With Quote
View Public Profile Visit microski's homepage!
 
Old 12-17-2004, 05:40 PM Re: Process a form and email it
Banned

Posts: 0
Trades: 0
sounds cool,ill try to do some things too.
wirlwind1 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Process a form and email it
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.32090 seconds with 12 queries