Jump to content

[SOLVED] mysql & php time not working.


jamesxg1

Recommended Posts

<?php session_start();

include 'Utilitys/Connection.php';
include 'Utilitys/Functions.php';

RedLogin();


$role = "1";	
$id = mt_rand(0, 9999999999); 
$time = date("F j, Y, g:i a");
$signup = date("F j, Y, g:i a");	
$username = protect($_POST['username']);	
$password = protect($_POST['password']);
$firstname = protect($_POST['FirstName']);	
$lastname = protect($_POST['LastName']);	
$email = protect($_POST['Email']);
$ip = $_SERVER['REMOTE_ADDR'];
$gender = protect($_POST['gender']);
$dobday = protect($_POST['dobday']);
$dobmonth = protect($_POST['dobmonth']);
$dobyear = protect($_POST['dobyear']);

$dobarr = array("$dobyear", "$dobmonth", "$dobday");
$dobsep = implode("-", $dobarr);
$dob = strtotime("$dobsep");

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

if (isset($username) && isset($password) && isset($firstname) && isset($lastname) && isset($email) && isset($gender) && isset($dobday) && isset($dobmonth) && isset($dobyear)) {


$flag = "INSERT INTO `users` (`id`, `username`, `password`, `firstname`, `lastname`, `email`, `role`, `time`, `signup`, `gender`, `ip`, `dob`)                      
VALUES('$id', '$username', md5('$password'), '$firstname', '$lastname', '$email', '$role', '$time', '$signup', '$gender', '$ip', '$dob')";	

$run = mysql_query($flag) or die(mysql_error());

header('Location: Login.php?i=1');


} else {

print "<p align='center'>Please Fill All Required Fields.</p>";

}
}

?>

 

in the mysql i have `dob` in a date format but its not working :(

 

anyone know why ? :(

Link to comment
https://forums.phpfreaks.com/topic/159934-solved-mysql-php-time-not-working/
Share on other sites

 

this works but why are you not just posting $dob to insert the new formatted time code.

<?php

$dobyear=1980;
$dobmonth=10;
$dobday=22;

$dobarr = array($dobyear,$dobmonth,$dobday);
$dobsep = implode("-",$dobarr);
$dob = strtotime("$dobsep");

echo date('dmy',$dob);

?>

 

this works but why are you not just posting $dob to insert the new formatted time code.

<?php

$dobyear=1980;
$dobmonth=10;
$dobday=22;

$dobarr = array($dobyear,$dobmonth,$dobday);
$dobsep = implode("-",$dobarr);
$dob = strtotime("$dobsep");

echo date('dmy',$dob);

?>

 

hiya, i dont fully undertand what you mean :S ???

 

i am using this so that when one of my customers registers and they input there DOB its sent as $dobyear, $dobmonth, $dobday and i need to join them and add it too a 'date' field in mysql, but it isnt working :S

you only need to insert dob in the database as the code you created

has created a timestamp anythink else is a wast in the database GET ME?

 

sorry you done that so sorry didnt look

 

if (isset($username) && isset($password) && isset($firstname) && isset($lastname) && isset($email) && isset($gender) && isset($dobday) && isset($dobmonth) && isset($dobyear)) {

 

 

only need $dob above dont you.

 

not needed

isset($dobday) && isset($dobmonth) && isset($dobyear)

 

$dob not even there in that code why not?

you only need to insert dob in the database as the code you created

has created a timestamp anythink else is a wast in the database GET ME?

 

sorry you done that so sorry didnt look

 

if (isset($username) && isset($password) && isset($firstname) && isset($lastname) && isset($email) && isset($gender) && isset($dobday) && isset($dobmonth) && isset($dobyear)) {

 

 

only need $dob above dont you.

 

not needed

isset($dobday) && isset($dobmonth) && isset($dobyear)

 

$dob not even there in that code why not?

 

 

<?php session_start();

include 'Utilitys/Connection.php';
include 'Utilitys/Functions.php';

RedLogin();


$role = "1";	
$id = mt_rand(0, 9999999999); 
$time = date("F j, Y, g:i a");
$signup = date("F j, Y, g:i a");	
$username = protect($_POST['username']);	
$password = protect($_POST['password']);
$firstname = protect($_POST['FirstName']);	
$lastname = protect($_POST['LastName']);	
$email = protect($_POST['Email']);
$ip = $_SERVER['REMOTE_ADDR'];
$gender = protect($_POST['gender']);
$dobday = protect($_POST['dobday']);
$dobmonth = protect($_POST['dobmonth']);
$dobyear = protect($_POST['dobyear']);

$dobarr = array("$dobyear", "$dobmonth", "$dobday");
$dobsep = implode("-", $dobarr);
$dob = strtotime("$dobsep");

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

if (isset($username) && isset($password) && isset($firstname) && isset($lastname) && isset($email) && isset($gender) && isset($dob)) {


$flag = "INSERT INTO `users` (`id`, `username`, `password`, `firstname`, `lastname`, `email`, `role`, `time`, `signup`, `gender`, `ip`, `dob`)                      
VALUES('$id', '$username', md5('$password'), '$firstname', '$lastname', '$email', '$role', '$time', '$signup', '$gender', '$ip', '$dob')";	

$run = mysql_query($flag) or die(mysql_error());

header('Location: Login.php?i=1');


} else {

print "<p align='center'>Please Fill All Required Fields.</p>";

}
}

?>

 

Changed :),

 

but it still isnt working it just has 0000-00-00 in the dat field ???

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.