jamesxg1 Posted May 27, 2009 Share Posted May 27, 2009 <?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 More sharing options...
redarrow Posted May 27, 2009 Share Posted May 27, 2009 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); ?> Link to comment https://forums.phpfreaks.com/topic/159934-solved-mysql-php-time-not-working/#findComment-843510 Share on other sites More sharing options...
jamesxg1 Posted May 27, 2009 Author Share Posted May 27, 2009 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 Link to comment https://forums.phpfreaks.com/topic/159934-solved-mysql-php-time-not-working/#findComment-843523 Share on other sites More sharing options...
redarrow Posted May 27, 2009 Share Posted May 27, 2009 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? Link to comment https://forums.phpfreaks.com/topic/159934-solved-mysql-php-time-not-working/#findComment-843531 Share on other sites More sharing options...
jamesxg1 Posted May 27, 2009 Author Share Posted May 27, 2009 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 ??? Link to comment https://forums.phpfreaks.com/topic/159934-solved-mysql-php-time-not-working/#findComment-843535 Share on other sites More sharing options...
redarrow Posted May 27, 2009 Share Posted May 27, 2009 make the database field int please INT(50) Link to comment https://forums.phpfreaks.com/topic/159934-solved-mysql-php-time-not-working/#findComment-843538 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.