Jump to content

PHP MySQL DateTime Insert?


doomdude

Recommended Posts

Hey guys.

 

I'm trying to add the date and time to a field in my database when someone presses a button. At current I've got:

 

Button:

 

<form action="includes/zero3.php" method="post">
			<input type="hidden" name="id" value="' . $row['id'] . '" />
			<input type="hidden" name="date" value="' . $row['id'] . '" />				
			<input type="submit" value="3 Day" class="button"></form>				
			</form>

 

zero3.php:

 

<?php

include("config.php");
$id = mysql_real_escape_string($_POST['id']);

  if (isset($_POST['id']))
{ 


$query=("UPDATE $dbdata SET pin='1' WHERE id='$id'");
mysql_query($query);

  $querytwo=("UPDATE $dbdata SET date='CURDATE()' WHERE id='$id'");
mysql_query($querytwo);

header("Location: /admin/accountnopin.php");
}
else
{
header("Location: /admin/accountnopin.php");
}

?>

 

Am I at all on the right tracks? I'll be looking to make it current date and time + 3 days after I've got the date working :S

 

 

Anyone got any advice?

Link to comment
https://forums.phpfreaks.com/topic/244741-php-mysql-datetime-insert/
Share on other sites

<?php

include("config.php");

$day3 = date('l d M Y', strtotime($start. '+3 day'));
$id = mysql_real_escape_string($_POST['id']);

  if (isset($_POST['id']))
{ 


$query=("UPDATE $dbdata SET pin='1',date='$day3' WHERE id='$id'");
mysql_query($query);



header("Location: /admin/accountnopin.php");
}
else
{
header("Location: /admin/accountnopin.php");
}

?>

 

Just makes the datetime to :

0000-00-00 00:00:00

 

Do I need to define $start as a date?

 

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.