php: Contact Page

for those of you interested in creating a contact page with a form (fields and submit button) that goes directly to your email, check this out. You simply need to copy and paste this code into the body of your html. You also need to put your email address in the part that says ‘YourEmailAddressHere’ and need to save the page as something like: contact.php, not something like contact.html. And thats it. Very easy to do.

<form name=”form1″ id=”form1″ method=”post” action=”<?=$PHP_SELF?>”>
<p>Name:
<input type=”text” name=”name” />
</p>
<p>&nbsp;</p>
<p>Email:
<input type=”text” name=”email” />
</p>
<p>&nbsp;</p>
<p>Subject:
<input type=”text” name=”subject” />
</p>
<p>&nbsp;</p>
<p>Message:
<textarea name=”comments” cols=”40″></textarea>
</p>
<p>&nbsp;</p>
<p>
<input name=”submitentry” type=”submit” value=”SUBMIT” />
<input type=”reset” name=”Submit2″ value=”Reset” />
</p>
</form>
<p>
<?php
if ($submitentry == “SUBMIT”){
$sql = “‘$name’, ‘$email’, ‘$comments'”;
$em = “‘$subject'”;
mail(‘YourEmailAddressHere’, $em, $sql);
echo(“<p>Your message has been sent!” . “</p>”);
}
?></p>

Posted in Adobe Dreamweaver, database and tagged , .

Leave a Reply