DarkShadowWing Posted September 8, 2009 Share Posted September 8, 2009 Hi all. I need to know how after a person submits some data, that it will return an error message until the next day? Example: I submit my data. it returns an error message until the next day. then it lets me submit again. <?php $conn = "localhost"; $user = "myuser"; $pass = "mypass"; $dbname = "metaldetect02"; $tbl2 = "users0002"; $con = mysql_connect($conn,$user,$pass); if (!$con) { die('Could not connect to database: "' . $dbname . '" because ' . mysql_error()); } mysql_select_db($dbname, $con); $sql="INSERT INTO $tbl2 (item, firstname, lastname) VALUES ('".$_POST[requireditem]."','".$_POST['requiredfirstname']."','".$_POST['requiredlastname']."')"; echo "Thanks for submitting your item, ".$_POST['requiredfirstname'].", ".$_POST['requiredlastname']."!<br>"; echo "Returning you to the previous page..."; echo "<script>setTimeout('document.location = \"./\";', 2000);</script>"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } mysql_close($con); ?> Quote Link to comment https://forums.phpfreaks.com/topic/173546-how-do-you-detect-after-a-user-has-submitted-data-if-its-the-next-day/ Share on other sites More sharing options...
sKunKbad Posted September 8, 2009 Share Posted September 8, 2009 Use a cookie or session Quote Link to comment https://forums.phpfreaks.com/topic/173546-how-do-you-detect-after-a-user-has-submitted-data-if-its-the-next-day/#findComment-914784 Share on other sites More sharing options...
micmania1 Posted September 8, 2009 Share Posted September 8, 2009 Please checkout this topic. http://www.phpfreaks.com/forums/index.php/topic,268419.0.html I think we came to the conclusion that it was best to store the submitted time in a database. Quote Link to comment https://forums.phpfreaks.com/topic/173546-how-do-you-detect-after-a-user-has-submitted-data-if-its-the-next-day/#findComment-914786 Share on other sites More sharing options...
DarkShadowWing Posted September 8, 2009 Author Share Posted September 8, 2009 i cant store it in a database because technically nobody has submitted data yet. what i need to do is use php to detect if after submission, it's the next day, if not then return error, if so, then allow for another submission. can someone please show me a working example? Quote Link to comment https://forums.phpfreaks.com/topic/173546-how-do-you-detect-after-a-user-has-submitted-data-if-its-the-next-day/#findComment-914795 Share on other sites More sharing options...
DarkShadowWing Posted September 8, 2009 Author Share Posted September 8, 2009 Ok, using this code, can someone at least help me modify it to detect whether or not its 24 hours later since the 1st submit? <?php $thismonth = date("m"); if ($thismonth=="01") // list January's dates { echo "<ul id=\"dateslist\">"; echo "<li>Wed, 7th January</li>"; echo "<li>Wed, 14th January</li>"; echo "<li>Wed, 21st January</li>"; echo "<li>Wed, 28th January</li>"; echo "</ul>"; } elseif ($thismonth=="02") // list February's dates { echo "<ul id=\"dateslist\">"; echo "<li>Wed, 4th February</li>"; echo "<li>Wed, 11th February</li>"; echo "<li>Wed, 18th February</li>"; echo "<li>Wed, 25th February</li>"; echo "</ul>"; } ?> <?php $conn = "localhost"; $user = "myuser"; $pass = "mypass"; $dbname = "metaldetect02"; $tbl2 = "users0002"; $con = mysql_connect($conn,$user,$pass); if (!$con) { die('Could not connect to database: "' . $dbname . '" because ' . mysql_error()); } mysql_select_db($dbname, $con); $sql="INSERT INTO $tbl2 (item, firstname, lastname) VALUES ('".$_POST[requireditem]."','".$_POST['requiredfirstname']."','".$_POST['requiredlastname']."')"; echo "Thanks for submitting your item, ".$_POST['requiredfirstname'].", ".$_POST['requiredlastname']."!<br>"; echo "Returning you to the previous page..."; echo "<script>setTimeout('document.location = \"./\";', 2000);</script>"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } mysql_close($con); ?> Quote Link to comment https://forums.phpfreaks.com/topic/173546-how-do-you-detect-after-a-user-has-submitted-data-if-its-the-next-day/#findComment-914801 Share on other sites More sharing options...
DavidAM Posted September 8, 2009 Share Posted September 8, 2009 Can you define "24 hours later since the 1st submit" ? Is it the first (or do you mean last) time submitted from this computer-user, or submitted with the exact same data, or submitted by the user logged into your site (I don't see a user login but maybe it's there). Give more detail on what you are trying to restrict and we might be able to give you some suggestions. Quote Link to comment https://forums.phpfreaks.com/topic/173546-how-do-you-detect-after-a-user-has-submitted-data-if-its-the-next-day/#findComment-914835 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.