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

 

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.