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