• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

form help

marcuscable

New Member
in html, how do I make a form that people can fill out and press submit to send it to my email?
someone had given me one before, but it was too small and it didn't look very good...is there any others?
 
let me see... 2 parts of your question:
1. do you how to make a form in html?
2. do you want to use html only, or use cgi, php... ?
 
1. the easiest way is HTML only, not not professional looking:

<form action="YOUR E-MAIL ADDRESS " method=post> (your form content) </form>
sender send e-mail via his email software.
i.e. YOUR E-MAIL ADDRESS = 123@456.com


2. not too easy (also not too hard), looking more professional:

(1) use CGI (cgi, pl, php, asp ... ), If you don't understand any cgi, it would be harder for you.

(2) confirm the server mail( ) function is enable.

(3) you just make a beautiful form, and set action as:
<form action="YOUR CGI NAME " method=post> (your form content) </form>
i.e. YOUR CGI NAME = yourcgi.php
OR yourcgi.cgi
OR yourcgi.pl
OR yourcgi.asp

I'm not sure it's clear for your or not. :)

by using PHP - You may go this page for more reference & teaching:
(The author's teaching is easy & clear, you know it then you can modify it)
Sending Form Data in E-Mail
http://www.thickbook.com/extra/php_email.phtml
more, In Form-Related...
http://www.thickbook.com/extra/index.html?t=fm
 
!!!

Originally posted by NONO
1. the easiest way is HTML only, not not professional looking:

<form action="YOUR E-MAIL ADDRESS " method=post> (your form content) </form>
sender send e-mail via his email software.
i.e. YOUR E-MAIL ADDRESS = 123@456.com


2. not too easy (also not too hard), looking more professional:

(1) use CGI (cgi, pl, php, asp ... ), If you don't understand any cgi, it would be harder for you.

(2) confirm the server mail( ) function is enable.

(3) you just make a beautiful form, and set action as:
<form action="YOUR CGI NAME " method=post> (your form content) </form>
i.e. YOUR CGI NAME = yourcgi.php
OR yourcgi.cgi
OR yourcgi.pl
OR yourcgi.asp

I'm not sure it's clear for your or not. :)

by using PHP - You may go this page for more reference & teaching:
(The author's teaching is easy & clear, you know it then you can modify it)
Sending Form Data in E-Mail
http://www.thickbook.com/extra/php_email.phtml
more, In Form-Related...
http://www.thickbook.com/extra/index.html?t=fm




I tried to do as thickbook.com had instructed me, but it doesn't work...maybe I typed something in wrong?
here is what I have:


HTML:



<HTML>
<HEAD>
<TITLE>E-Mail Form</TITLE>
</HEAD>
<BODY>

<FORM method="POST" action="do_sendform.php">

<P>Your Name:<br>
<INPUT type="text" name="sender_name" size=100>
</p>

<P>Your E-Mail Address:<br>
<INPUT type="text" name="sender_email" size=100>
</p>

<P>Message:<br>
<textarea name="message" cols=50 rows=50></textarea>
</p>

<INPUT type="submit" value="Send This Form">

</FORM>

</BODY>
</HTML>


PHP:

<?php

$msg = "Sender Name:\t$_POST[sender_name]\n";
$msg .= "Sender E-Mail:\t$_POST[sender_email]\n";
$msg .= "Message:\t$_POST[message]\n\n";
$recipient = "webmaster@shplooky.com";
$subject = "Shplooky Feedback";
$mailheaders = "From: Shplooky Network <> \n";
$mailheaders .= "Reply-To: $_POST[sender_email]\n\n";
mail($recipient, $subject, $msg, $mailheaders);
echo "<HTML><HEAD><TITLE>Form Sent!</TITLE></HEAD><BODY>";
echo "<H1 align=center>Thank You, $_POST[$sender_name]</H1>";
echo "<P align=center>Your message has been sent.</P>";
echo "</BODY></HTML>";
?>

Can anyone help me????:confused:
 
First, please make sure PHP works on your server. :p

1. PHP got error, HTML is OK:
\t (means "tab", you may delete it)

$xxx : a name start with $ is a variable.
In this sample, $xxx get data from your html form <INPUT name="xxx">, so, the name must be same.

$_POST[sender_name] is not equal to sender_name, see? ;)

========================================
FORM & PHP :

<FORM method="POST" action="CGI.php">
sender: <INPUT type="text" name="A" size=100>
email: <INPUT type="text" name="B" size=100>
message: <textarea name="C" cols=50 rows=50></textarea>
<INPUT type="submit" value="Send This Form">
</FORM>


CGI.php :
<?
$msg = "Sender Name: $A\n";
$msg .= "Sender E-Mail: $B\n";
$msg .= "Message: $C\n\n";
$recipient = "webmaster@shplooky.com";
$subject = "Shplooky Feedback";
$mailheaders = "From: Shplooky Network <> \n";
$mailheaders .= "Reply-To: $B\n\n";
mail($recipient, $subject, $msg, $mailheaders);
echo "<HTML><HEAD><TITLE>Form Sent!</TITLE></HEAD><BODY>";
echo "<H1 align=center>Thank You, $A</H1>";
echo "<P align=center>Your message has been sent.</P>";
echo "</BODY></HTML>";
?>

========================================
So, your php should be:

$msg = "Sender Name:\t$sender_name\n";
$msg .= "Sender E-Mail:\t$sender_email\n";
$msg .= "Message:\t$message\n\n";
$recipient = "webmaster@shplooky.com";
$subject = "Shplooky Feedback";
$mailheaders = "From: Shplooky Network <> \n";
$mailheaders .= "Reply-To: $sender_email\n\n";
mail($recipient, $subject, $msg, $mailheaders);
echo "<HTML><HEAD><TITLE>Form Sent!</TITLE></HEAD><BODY>";
echo "<H1 align=center>Thank You, $_POST[$sender_name]</H1>";
echo "<P align=center>Your message has been sent.</P>";
echo "</BODY></HTML>";

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
P.S. you may delete <> (in the $mailheaders line)


2. check the php file name is SAME as your html <FORM method="POST" action="do_sendform.php">


3. if can't, try to delete "\t", and then try again.
(I've ever tried to delete \t, and then OK. I don't know why.)

Good luck! :cool2:
 
Back
Top