How do I make a form which emails me the data entered?

  • pimpmasta
  • Student
  • Student
  • pimpmasta
  • Posts: 89

Post 3+ Months Ago

ok everyone i need help a lot.. i dont know how to make a form so that it e-mails the information inputted by the user directly to my e-mail...or so that it can write the information to a file on the server. either one would be great. i have been searching forever and no one ever seems to know exactly how.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23455
  • Loc: Woodbridge VA

Post 3+ Months Ago

There's quite a few ways to do it, but it would help to know how you want to do it and what your host's server will support. For example, I use Matt's formmail.pl for CGI, and I use JMAIL for ASP, and I know that PHP has it's own script/s that can be use even though I haven't tried them yet. Most of these can be found free on the internet. For example, for CGI Matt's formmail can be found at Matt's Script Archive:

http://www.scriptarchive.com/formmail.html

And an example of JMAIL:

http://www.webworld.ie/members/section4/jmail.asp

To give anything more detailed let us know what your server supports so we know what you have to work with.
  • pimpmasta
  • Student
  • Student
  • pimpmasta
  • Posts: 89

Post 3+ Months Ago

yes i tried mats script page but i am new at making websites and i don't have a clue what all the complicated language on the script means...well i do have a clue i can make basic html pages and framesets but that is about it. as far as giving you more detail goes... i dont know if i can..i dont know the web terms so your out of luck.. to explain what i want a bit better, i would just like it so that when the user presses the submit button on the form the information inputted in the form areas is sent to my e-mail..or it is written to a file on the server... and i dont have my own server i just use free ones.. its more of a fun thing for me to do :D
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23455
  • Loc: Woodbridge VA

Post 3+ Months Ago

There is very little you need to understand about the formmail script. Primarily, you need to be certain that the path to Perl is correct. Your host should provide an FAQ or knowledge base to tell you the correct path to Perl. Typically it is going to be the default:
Code: [ Select ]
#!/usr/bin/perl

If it is different your host should tell you and then edit that line exactly as they indicate. You may also need to add the following line of code, depending upon your host's configuration:
Code: [ Select ]
use LWP::UserAgent;

So your first three lines of code would look like this:
Code: [ Select ]
#!/usr/bin/perl
# Perl module for HTTP REFERER Check
use LWP::UserAgent;
  1. #!/usr/bin/perl
  2. # Perl module for HTTP REFERER Check
  3. use LWP::UserAgent;


(*side note - you should be able to use any text editor or HTML editor to edit the perl script for formmail)

The next edit would be the $mailprog. This is the original from v 1.92 (which is the most current version you should be using):
Code: [ Select ]
$mailprog = '/usr/lib/sendmail -i -t';

Here's an example of how it could be changed:
Code: [ Select ]
$mailprog = '/usr/lib/sendmail -f youremail@yourdomain.com -t';

You may or may not need to edit that depending upon your host. I had to edit this line because of special spam filters my host has in place. Check with your host.

The next edit would be @referers. This is a security feature that prevents spammers from hacking your form. Here is the original:
Code: [ Select ]
@referers = (ERROR);

Here's an example of the edit:
Code: [ Select ]
@referers = ('yourdomain.com','www.yourdomain.com','255.255.255.1 ');

You should include any variations of your domain.

That should be all the editing you have to do to your Perl script to make it work. (*sidenote -- some hosts require that the file extension for the script is .pl, others require .cgi -- in either case you'll need to upload the edited file to your cgi-bin)

As far as the form itself, that will be created on a separate HTML page. Here's a simple example:

Code: [ Select ]
<html>
<head>
<title>Form</title>
</head>
<body>
<FORM method="POST" action="/cgi-bin/formmail.pl">    
   <input type="hidden" name="required" value="name,email" />Your Name:
   <input class="form" tabindex="1" type="text" size="30" name="name" /><br />Your Email:        
   <input class="form" tabindex="2" type="text" size="30" name="email" /><br />
   <input class="form" tabindex="3" type="submit" value="Submit" title="Submit this form"><br />
</form>
</body>
</html>
  1. <html>
  2. <head>
  3. <title>Form</title>
  4. </head>
  5. <body>
  6. <FORM method="POST" action="/cgi-bin/formmail.pl">    
  7.    <input type="hidden" name="required" value="name,email" />Your Name:
  8.    <input class="form" tabindex="1" type="text" size="30" name="name" /><br />Your Email:        
  9.    <input class="form" tabindex="2" type="text" size="30" name="email" /><br />
  10.    <input class="form" tabindex="3" type="submit" value="Submit" title="Submit this form"><br />
  11. </form>
  12. </body>
  13. </html>

Hope that helps. Good luck.
  • pimpmasta
  • Student
  • Student
  • pimpmasta
  • Posts: 89

Post 3+ Months Ago

wow um,.... i'm a newb and i have no idea what you just said :oops: so is that bottom code you displayed the code for the whole form? and how do i edit it so that it sends to my E=mail?? or file on the web?? god i'm confused as hell. :?
  • pimpmasta
  • Student
  • Student
  • pimpmasta
  • Posts: 89

Post 3+ Months Ago

Using your code method i just made this code but it doesnt work... can you tell me if i did anything wrong?

Code: [ Select ]
#!/usr/bin/perl
# Perl module for HTTP REFERER Check
use LWP::UserAgent;
$mailprog = '/usr/lib/sendmail -f thornerscott@hotmail.com.com -t';
Code:
@referers = (ERROR);
<html>
<head>
<title>Form</title>
</head>
<body>
<FORM method="POST" action="/cgi-bin/formmail.pl">  
   <input type="hidden" name="required" value="name,email" />Your Name:
   <input class="form" tabindex="1" type="text" size="30" name="name" /><br />Your Email:   
   <input class="form" tabindex="2" type="text" size="30" name="email" /><br />
   <input class="form" tabindex="3" type="submit" value="Submit" title="Submit this form"><br />
</form>
</body>
</html>
  1. #!/usr/bin/perl
  2. # Perl module for HTTP REFERER Check
  3. use LWP::UserAgent;
  4. $mailprog = '/usr/lib/sendmail -f thornerscott@hotmail.com.com -t';
  5. Code:
  6. @referers = (ERROR);
  7. <html>
  8. <head>
  9. <title>Form</title>
  10. </head>
  11. <body>
  12. <FORM method="POST" action="/cgi-bin/formmail.pl">  
  13.    <input type="hidden" name="required" value="name,email" />Your Name:
  14.    <input class="form" tabindex="1" type="text" size="30" name="name" /><br />Your Email:   
  15.    <input class="form" tabindex="2" type="text" size="30" name="email" /><br />
  16.    <input class="form" tabindex="3" type="submit" value="Submit" title="Submit this form"><br />
  17. </form>
  18. </body>
  19. </html>


and by the way you must be a genious :)
  • dreamer7
  • Student
  • Student
  • dreamer7
  • Posts: 95
  • Loc: UK

Post 3+ Months Ago

Well that script from matts archive i always found looked harder than the one i made up pimpmasta try this script out...
http://www.ozzu.com/viewtopic.php?t=934&sid=ed61e490dc1bb70a4143cd79f6960969
d7
  • pimpmasta
  • Student
  • Student
  • pimpmasta
  • Posts: 89

Post 3+ Months Ago

yea ok thanx...um would there be a way to customize it to sent it to me? and if so how would i go about doing that... any help would be greatly appreciated. By the way if you were wondering what i'm doing with this form i'm making a signup form for my site in progress. Its not much but i'm just learning. http://www.pimpsprays.owns.it
  • dreamer7
  • Student
  • Student
  • dreamer7
  • Posts: 95
  • Loc: UK

Post 3+ Months Ago

Well tell me how you want to customise it and i'll see if you can do it or not sound ok? and lol u in a counterstrike clan? i used to be in a delta force squad making sites for them so i have like a bit of experience in making squad/clan sites.
dj

Post Information

  • Total Posts in this topic: 9 posts
  • Users browsing this forum: No registered users and 63 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.