Anyone have a quick "Contact Us" form code?

Jcsarokin

Power Member
Joined
Mar 2, 2009
Messages
718
Reaction score
1,035
Been Googling it for a bit and they all want me to sign up to their bullshit site and spam me (always read the privacy policy :cool:).

Anyone here have some quick code for a contact us form lying around?

Name
Email
Subject
(website optional)
Body

or something to that extent.

Id really appreciate it (+Rep)
 
PHP:
<?php
if (empty($_POST['submit'])) {
    echo "<table border=\"0\"><form method=\"post\">
<tr>
<td>Body:</td>
<td><textarea name=\"body\" style=\"width: 250px; height: 100px\"></textarea></td>
</tr>
<tr>
<td>Name:</td>
<td><input type=\"text\" name=\"name\" style=\"width: 250px\"></td>
</tr>
<tr>
<td>e-mail</td>
<td><input type=\"text\" name=\"email\" style=\"width: 250px\"></td>
</tr>
<tr>
<td>e-mail</td>
<td><input type=\"text\" name=\"subject\" style=\"width: 250px\"></td>
</tr>
<tr>
<td> </td>
<td><input type=\"submit\" name=\"submit\" value=\"Send\"> 
<input type=\"reset\" value=\"Od nowa\"></td></form>
</tr>
</table>";
}

elseif (!empty($_POST['body']) && !empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['subject'])) {

    $message = $_POST['body'];
	  $subject = $_POST['subject'];
    $header = "From: $_POST[name] <$_POST[email]>";

    @mail("[email protected]","$subject","$message","$header")
    or die('Error');
    
    echo "<div align=\"center\"><strong>Success!</strong></div>";
}

else echo "<span style=\"color: #FF0000; text-align: center;\">Error!</span>";

?>
 
Back
Top