I have added a contact form to my site and it seems to be working. What I would like to do know, is add some type of feature were an individual is limited on the number of times they can submit my form over a given time interval(lets say five minutes).
Below you will find my contact form and contact.php file.
Code:
contact form
<form id="form" method="post" action="contact.php" enctype="multipart/form-data" name="form">
<strong><u>All fields marked * are required</u></strong>
<br /><br style="line-height:15px;" />
<div class="col_box">
<div class="col_box_1">
<strong>Subject</strong>
<div class="t_form"><input name="content" type="text" value="" /></div>
<strong>Name *</strong>
<div class="t_form"><input name="visitor" type="text" value="" /></div>
<strong>Email *</strong>
<div class="t_form"><input name="visitormail" type="text" value="" /></div>
<br /><br style="line-height:3px;" />
<strong><a href="http://www.***.com/verification.html" onclick="window.open('http://www.***.com/verification.html','popup','width=400,height=500,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false">whats this?</a></strong>*<img src="captcha.php"><input type="text" name="vercode" value="Place above code here" /><br>
</form>
</div>
<div class="col_box_2">
<strong>Message *</strong>
<textarea name="details" cols="2" rows="2" ></textarea>
<strong style="margin:0 15px 0 40px;">
<input type="submit" name="submit" value="Submit"><input type="reset" name="Submit2" value="Reset"> </div>
<div class="clear"></div>
</div>
</form>
</div>
Code:
contact.php file
<?php
$content = $_POST['content'];
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$details = $_POST['details'];
if (eregi('http:', $details)) {
die ("We don't allow visitors to submit website links due to security reasons, Please click the browser back button and remove the link.");
}
if(empty($visitor) || empty($visitormail) || empty($details )) {
echo "<h2>Use the browser back button and fill in all required form fields</h2>\n";
die ("");
}
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "<h2>Use browser back button and enter a valid e-mail address</h2>\n";
$badinput = "<h2>A valid email looks like this: someone@someone.com</h2>\n";
echo $badinput;
die ("");
}
session_start();
if ($_POST["vercode"] != $_SESSION["vercode"] OR $_SESSION["vercode"]=='') {
echo "<h2>Use browser back button and enter the correct verification code.</h2>\n";
die ("");
}
$todayis = date("l, F j, Y") ;
$content = $content ;
$subject = $content;
$details = stripcslashes($details);
$message = " $todayis \n
Subject: $content \n
Message: $details \n
From: $visitor ($visitormail)\n
";
$from = "From: $visitormail\r\n";
mail("email@email.com", $subject, $message, $from);
?>
<p align="center">
Date: <?php echo $todayis ?>
<br />
Email was recieved - Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> )
<br />
Subject: <?php echo $subject ?>
<br />
Message:<br />
<?php $notesout = str_replace("\r", "<br/>", $details);
echo $notesout; ?>
<br />
<br /><br />
<a href="contactus.html"> Back to contact page </a>
</p>
Any help would be greatly appreciated.
If you also notice anything else that can be added or changed please let me know
Thanks