Jump to content

Need help with timestamp table in sql..


DarkShadowWing

Recommended Posts

If I wanted to create a table in my database with TIMESTAMP DEFAULT CURRENT_TIMESTAMP, and wanted to check if the same person submitted data before the next day and send an error message depending on if 24 hours has passed on the same person, how would i do that?

 

how could i use this "WHERE timesamp >NOW() +INTERVAL 1 DAY", to detect if its been 24 hours or not since that person's 1st submit?

 

here's the table:

 

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

?>

 

ANY help is GREATLY appreciated! :)

Link to comment
https://forums.phpfreaks.com/topic/173596-need-help-with-timestamp-table-in-sql/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.