Jump to content

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


DarkShadowWing

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

?>

Link to comment
Share on other sites

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

?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.