View Single Post
Old 01-21-2006   #9 (permalink)
sancho
"Enter Random Text Here"
 
sancho's Avatar
 
Join Date: Jun 2005
Location: Handsacre, UK
Posts: 37

Send a message via MSN to sancho Send a message via Skype™ to sancho
This is your contact form which sends to itself and sends the email

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Contact Information</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
body {
font-family:Arial, Tahoma, sans-serif;
font-size:0.6em;
margin:35px;
color:#000000;}
label {
margin: 0;
margin-top:0.3em;
text-align:right;
width:70px;
float:left;
text-transform:uppercase;
  }
fieldset {
  background-color:#ffffff;
  border:solid 1 #000; /* Opera doesn't get border:none or border:0 on fieldsets */
  width:300px;
  }
legend {
width:100px;
height:0px;
color:#000000;
font-size:2.5em;
padding-left:0em;
position:inherit;
top:-1.5em;
text-transform:uppercase;
font-weight:bold;
letter-spacing:-1px;
}

.br {display:none;}  
  
.textfield {
font:1.1em  Verdana, Arial, Helvetica, sans-serif ;
color:#000000;
margin:3px;
height:18px;
border:solid 1 #000000;
padding: 0px 0px;
width:200px;

width:187px;
}
fieldset>input.textfield {
}
textarea {
font:1.1em Arial, Tahoma, sans-serif;
color:#000000 ;
margin:3px;
height:165px;
border:solid 1 #000000;
padding: 0 8px;
width:200px;
width:190px;
}
fieldset>textarea {
}
.submit {
margin:3px;
height:18px;
border:solid 1 #000000;
width:80px;
font:1.1em Verdana, Arial, Helvetica, sans-serif;
color:#000000 ;
text-transform:uppercase;
 }
</style>
</head>

<body>
<?php
if(isset($_POST['sendMail']))
{

	$to = "mst0ke@yahoo.com";
	$name = trim($_POST['name']);
	$email = trim($_POST['email']);
	$message = trim($_POST['comment']);

	if(((empty($name))||(empty($email))||(empty($message))))
	{

		echo 'Sorry, you forgot to fill out some required fields. ';
		echo '<a href="javascript:history.back(1)">Try again</a>';

	} 
	else 
	{

		if(!strstr($email , "@"))
		{

			echo 'Please enter a valid email address. ';
			echo '<a href="javascript:history.back(1)">Try again</a>';
		
		}
		else
		{

			$send = mail($to , "Contact message from YourWebsite" , "This email was sent from your website.\n\n".$name." send this message from ".$email.":\n\n".$message."\n\nClick reply and it will send to this email." , "From: Contact Form Reply-to: ".$email);

			if($send)
			{

				echo 'Mail sent successfully.';

			} 
			else 
			{

				echo 'There was an error sending the mail!';

			}
		}
	}
}
else
{
?>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post" enctype="multipart/form-data">
<fieldset class="fieldset">
<legend>Contact Form</legend>
<label for="name">Name:</label><br class="nobr" />
<input name="name" type="text" class="textfield"  id="name"  />
<br />
<label for="email">Email:</label><br class="nobr" />
<input name="email" type="text" class="textfield" id="email" />
<br/>
<label for="phone">Phone:</label><br class="nobr" />
<input name="website" type="text" class="textfield" id="website" />
<br />
<label for="comment">Comment:</label><br class="nobr" />
<textarea cols="30" rows="15" name="comment" id="comment" class="textarea"></textarea>
<br />
<label for="submit">&nbsp;</label><br class="nobr" />
<input name="sendMail" type="submit" class="submit" id="sendMail" value="submit" />
</fieldset>
</form>
<?php
}
?>
</body>
</html>
__________________

Portfolio: www.simonmclaughlin.co.uk
Cheap UK hosting: www.qubithosting.com

Last edited by sancho; 01-22-2006 at 06:50 PM..
sancho is offline