View Full Version : form help
marcuscable
February 19th, 2003, 09:12
In html, how do I create an on-line form that when a user types their info and clicks "submit" it will e-mail me the form?
pro5ject
February 19th, 2003, 09:19
here is a simple php page that does just what you want, and also sends the users ip address.
You must input your own email address up top for it to work.
<?
$admin = "youremail@yoursite.com";
$ip = $REMOTE_ADDR;
//error message maker
function error_message($msg) {
echo "<HTML><HEAD></HEAD><BODY>";
echo "<script>alert(\"error: $msg\");history.go(-1)</script>";
echo "</body></HTML>";
}
function msg_box(){
?>
<HTML>
<CENTER>
<BODY>
<body bgcolor="#ffffff">
<form action="?action=submit" method="post">
<input type="text" name="name" value="Your Name" onfocus="this.value=''" class="text" style="border:1px solid $color4; border-style: solid; background-color:$color5;" size="15"><br>
<input type="text" name="email" value="Your Email" onfocus="this.value=''" class="text" style="border:1px solid $color4; border-style: solid; background-color:$color5;" size="15"><br>
<textarea name="msg" value="msg" onfocus="this.value=''" class="text" style="border:1px solid $color4; border-style: solid; background-color:$color5;" cols="13" rows="10"></textarea><br>
<input type="submit" name="Submit" value="Submit" class="text" style="border:1px solid $color4; border-style: solid; background-color:$color6;">
</form>
</body>
</CENTER>
</html>
<?
}
if(!$action) msg_box();
elseif($action =="submit"){
if($name == "Your Name" OR $name == ""){
error_message('Please input a name');
exit();
}
if($email == "Your Email" OR ""){
error_message('Please input a Email Address');
exit();
}
if($msg == "msg" OR $msg == ""){
error_message('Please input a Message');
exit();
}
$email_msg = "Message from: " . $name . "
Email Address:" . $email . "
Message:" . $msg . "
IP:" . $ip;
if (!mail($admin , "Website Message",$email_msg, $email)){
echo "An error has occured in sending your email contact " . $admin;
exit();
}
else{
echo "Thank you for submiting an email";
}
}
?>
marcuscable
February 19th, 2003, 13:20
Thank you!:D
Powered by vBulletin® Version 4.1.7 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.