Search This Blog

Thursday, August 14, 2014

How to Make a Simple Feedback Form using HTML



Steps to making a feedback form on your website where people can email you information.
1. Copy the below code
2. Replace the following:
a. FormMail Demo: With your page title.
b. www.mydomain.com: With your domain name.
c. youremail@here.com: With your website email address.
3. Replace the words in with whatever you want that part of the form to say.
a. Whatever you want to say here
b. Visitor E-Mail
c. E-Mail Content
d. E-Mail Me!
4. Save it as a .html (e.g form.html)
5. Upload and you are done.

Note: Make sure you use an email address on the server as you can’t use an outside email address for security reasons. You can always use a forwarder to send it to an outside email address as well.
Form script without any validation:
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<html>
<head>
<title>FormMail Demo</title>
</head>
<body>
<form action="http://www.mydomain.com/formmail.php" method="post">
<input type="hidden" name="recipient" value="youremail@here.com">
<input type="hidden" name="subject" value="FormMail E-Mail">
Whatever you want to say here<br /><br />
<input type="text" name="email" size="20" value="Visitor E-Mail"><br />
<input type="text" name="tellme" size="20" value="E-Mail Content"><br /><br />
<input type="submit" name="submit" value="E-Mail Me!">
<input type="hidden" name="redirect" value="http://yourdomain.com/redirecto.html">
</form>
</body>
</html>
The PHP Code for the form:
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php?
// Contact
subject?$subject ="subject";
// Details
$message="tellme";
// Mail of sender
$mail_from="email";
// From
$header="<email>";
// Enter your email address
$to ='yourmail@here.com';
$send_contact=mail($to,subject,tellme);
// Check, if message sent to your email
// display message "We've recived your information"
if($send_contact){?
echo "We've recived your contact information";?} else {?echo "ERROR";?}
?>
Form with Javascript validation:
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<html>
<head>
<title>FormMail Demo</title>
<script type="text/javascript">
function hgcheck(thisform)
{
with (thisform)
 {
 if (hgrequired(email,"Visitor E-Mail required!")==false){
   email.focus();
   return false;
   }
 if (hgrequired(tellme,"E-Mail Content required!")==false){
   email.focus();
   return false;
   }
 }
}
function hgrequired(newfield,newmessage)
{
with (newfield)
 {
 if (value)
   return true;
 else
   {
   alert(newmessage);
   return false;
   }
 }
}
</script>
</head>
<body>
<form action="http://www.mydomain.com/cgi-sys/formmail.pl" method="post" onsubmit="return hgcheck(this)">
<input type="hidden" name="recipient" value="youremail@here.com">
<input type="hidden" name="subject" value="FormMail E-Mail">
Whatever you want to say here<br /><br />
Visitor E-Mail: <input type="text" name="email" size="20" value=""><br />
E-Mail Content: <input type="text" name="tellme" size="20" value=""><br /><br />
<input type="submit" name="submit" value="E-Mail Me!">
<input type="hidden" name="redirect" value="http://www.mydomain.com/path">
</form>
</body>
</html>

No comments: