Jump to content

how do you detect after a user has submitted data, if it's the next day?


Recommended Posts

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);

?>

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.

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?

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);

?>

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.