I am having an issue with cookies in my php. Here is the scenario. I have a form that when you access it you are entering as a guest. When you fill out the form and submit you are shown the date submitted and all the info you typed in. Now, when you go back to the form page, it recognizes the cookie and tells you cannot send another email in a 24 hours period.
All this works fine. What I can't figure out is how to tell the user what time they submitted the original email on. I assume it can be retrieved form the cookie, but for the life of me I can't figure out how.
Here is the form page contact.php
<?php
setcookie("assign", "ProfClower", time()+86400);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Messer Consulting Services .: Contact Us :.</title>
<link rel="STYLESHEET" type="text/css" href="styles.css">
<style type="text/css">
<!--
td.form { color: #ffffff; font-family: "Verdana","Arial"; font-size: 11; }
td.main { color: #000000; font-family: "Verdana","Arial"; font-size: 12; }
font.form_check { color: red; }
input { font-family: "Verdana","Arial"; color:#606060; font-size: 11px; }
textarea { font-family: "Verdana","Arial"; color:#606060; font-size: 11px; }
div#form_box { margin: 2px; width: 651px; border: 1px; border-style: solid; border-color: #606060; background: #64798B; padding: 5px; }
-->
</style>
</head>
<body>
<div align="center">
<div class="contentBorder">
<div class="mainContent">
<br>
<table width="651" cellpadding="2" cellspacing="3" border="0">
<tr>
</td>
<?php
if (isset($_COOKIE["assign"]))
echo "Welcome " . $_COOKIE["assign"] . "!<br />";
else
echo "Welcome guest!<br />";
?>
</td>
</tr>
<tr>
<td class="bodyText">We would love to hear from you! Please feel free to fill out the form below with any questions or comments you may have</td></tr>
<tr>
<td class="bodyText">Please fill out and submit the form on this page to contact us. We will get back to you
as soon as we can. Note that fields marked with (<font class="form_check">*</font>) are
required fields.
</td>
</tr>
<tr>
<td class="bodyText">
<form method="post" action="sendeail.php">
<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
$todayis = date("l, F j, Y, g:i a") ;
?>
<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />
<input type="hidden" name="todayis" value="<?php echo $todayis ?>" />
Your Name: <br />
<input type="text" name="visitor" size="35" />
<br /><br />
Your Email:<br />
<input type="text" name="visitormail" size="35" />
<br /><br />
Mail Message:
<br />
<textarea name="notes" rows="4" cols="40"></textarea>
<br /><br />
<?php
if (isset($_COOKIE["assign"]))
echo "You sent an email on ". $_COOKIE["todayis"] ." with the subject Contact Inquiry. You may not send more than one email in any 24 hour period.";
else
echo "<input type=submit value=Send Mail>";
?>
</form>
</td>
</tr>
</table>
</div>
</div>
</div>
</body>
</html>
and here is the action page.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sendemail Script</title>
</head>
<body>
<?php
$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$notes = $_POST['notes'];
if (eregi('http:', $notes)) {
die ("Do NOT try that! ! ");
}
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
die ("Go back! ! ");
}
if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
die ("Use back! ! ");
}
$todayis = date("l, F j, Y, g:i a") ;
$subject = "Contact Inquiry";
$notes = stripcslashes($notes);
$message = " $todayis [EST] \n
Message: $notes \n
From: $visitor ($visitormail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";
$from = "From: $visitormail\r\n";
mail("nofx@gti.net", $subject, $message, $from);
?>
<p align="center">
Date: <?php echo $todayis ?>
<br />
Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> )
<br />
Message:<br />
<?php $notesout = str_replace("\r", "<br/>", $notes);
echo $notesout; ?>
<br />
<?php echo $ip ?>
</p>
</body>
</html>
Any help would be appreciated.