• 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 create an on-line form that when a user types their info and clicks "submit" it will e-mail me the form?
 
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";
}
}

?>
 
Back
Top