L Posted June 24, 2007 Share Posted June 24, 2007 Hello, I have two separate problems, so i decided to keep them in one topic. My first problem is with the date and time...well mostly the time. I have a comments script running where the date and time is inserted into the database. $date = date("F j, Y | h:i A"); if ($_POST['submit']) { mysql_query("INSERT INTO `news` (`user`, `subject`, `news`, `date`) VALUES ('".$user."','".$subject."','".$news."','".$date."')");} This all works, but when i check the time in the database, and when the comment is shown, the time is off by an hour. I had myself and a friend test it, and we both got wrong times. I think the problem is that the $date variable is picking the info from the server, which i don;t want. How can I make it so I can take the time and date, from the persons computer show instead? Problem #2. My second problem is about registration. I created a login script with other features....but the only part that's not working is the confirm password part. I want a user to type the same password two times, one in a Password: Input and the other in a Confirm Password: Input. Does anyone know how i can do this? Thank you for your time ~L Link to comment https://forums.phpfreaks.com/topic/57011-time-and-resgister-problem/ Share on other sites More sharing options...
teng84 Posted June 24, 2007 Share Posted June 24, 2007 try the mysql function instead of php. use now for the time and even for the date now() you can use js or php for php compare the post of two password and for js use the getElementByid() to compare the two Link to comment https://forums.phpfreaks.com/topic/57011-time-and-resgister-problem/#findComment-281611 Share on other sites More sharing options...
L Posted June 24, 2007 Author Share Posted June 24, 2007 would this work for the passswords? if ($md5pass != $md5pass2) { echo 'The passwords you entered do not match' .' - please go back and try again.'; } $md5pass2 = md5($_POST['pass2']); $md5email = md5($_POST['email']); Link to comment https://forums.phpfreaks.com/topic/57011-time-and-resgister-problem/#findComment-281616 Share on other sites More sharing options...
teng84 Posted June 24, 2007 Share Posted June 24, 2007 dont use the hashing its useless use the post firs for comparing input hashing is use for storage purpose Link to comment https://forums.phpfreaks.com/topic/57011-time-and-resgister-problem/#findComment-281617 Share on other sites More sharing options...
L Posted June 24, 2007 Author Share Posted June 24, 2007 hmm...um...im a lil lost, how would the code look like? Link to comment https://forums.phpfreaks.com/topic/57011-time-and-resgister-problem/#findComment-281619 Share on other sites More sharing options...
teng84 Posted June 24, 2007 Share Posted June 24, 2007 <? if ($_POST['your variable1'] != $_POST['your variable2']) { echo 'The passwords you entered do not match' .' - please go back and try again.'; } then if ok do the hashing now ?> hope that helps Link to comment https://forums.phpfreaks.com/topic/57011-time-and-resgister-problem/#findComment-281621 Share on other sites More sharing options...
L Posted June 24, 2007 Author Share Posted June 24, 2007 yah that does...but one more thing...what do you mean by hashing? I'm not familiar with terms...i can just recognize code, sorry for the hastle Link to comment https://forums.phpfreaks.com/topic/57011-time-and-resgister-problem/#findComment-281622 Share on other sites More sharing options...
teng84 Posted June 24, 2007 Share Posted June 24, 2007 encryption or your md5 Link to comment https://forums.phpfreaks.com/topic/57011-time-and-resgister-problem/#findComment-281624 Share on other sites More sharing options...
L Posted June 24, 2007 Author Share Posted June 24, 2007 encryption happens as i add it to the database, right? Link to comment https://forums.phpfreaks.com/topic/57011-time-and-resgister-problem/#findComment-281629 Share on other sites More sharing options...
teng84 Posted June 25, 2007 Share Posted June 25, 2007 no if you have confirmed that the two variables are equal then do the encryption and save it to your db Link to comment https://forums.phpfreaks.com/topic/57011-time-and-resgister-problem/#findComment-281631 Share on other sites More sharing options...
L Posted June 25, 2007 Author Share Posted June 25, 2007 OH!!! I get it now, thanx for your help. But back to the time problem... try the mysql function instead of php. use now for the time and even for the date now() you can use js or php $date = date("F j, Y | h:i A"); if ($_POST['submit']) { mysql_query("INSERT INTO `news` (`user`, `subject`, `news`, `date`) VALUES ('".$user."','".$subject."','".$news."','".$date."')");} Im not familiar with mysql functions....would i replace the php date stuff with $date = date("now() | now"); ? Link to comment https://forums.phpfreaks.com/topic/57011-time-and-resgister-problem/#findComment-281637 Share on other sites More sharing options...
teng84 Posted June 25, 2007 Share Posted June 25, 2007 if ($_POST['submit']) { mysql_query("INSERT INTO `news` (`user`, `subject`, `news`, `date`) VALUES ('".$user."','".$subject."','".$news."',now())") Link to comment https://forums.phpfreaks.com/topic/57011-time-and-resgister-problem/#findComment-281643 Share on other sites More sharing options...
L Posted June 25, 2007 Author Share Posted June 25, 2007 ohh..alright....but when i upload it, it shows up blank <?PHP include("db.php"); ?> <form id='1' name='1' method='post'> <table width="90%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><div align="right">Alias: </div></td> <td><input name="user" type="text" size="30" value=""></td> </tr> <tr> <td><div align="right">Subject: </div></td> <td><input name="subject" type="text" size="30" value=""></td> </tr> <td><div align="right">News: </div></td> <td><textarea name="news" cols="45" rows="5" wrap="VIRTUAL"></textarea></td> </tr> <tr> <td></td> <td colspan="2"> <input type="submit" name="submit" value="Submit News"></td> </tr> </table> </form> <?PHP $user = addslashes(strip_tags($_POST['user'])); $subject = addslashes(strip_tags($_POST['subject'])); $news = addslashes(strip_tags($_POST['news'],'<a>')); $date = date("F j, Y | h:i A"); if ($_POST['submit']) { mysql_query("INSERT INTO `news` (`user`, `subject`, `news`, `date`) VALUES ('".$user."','".$subject."','".$news."',now())") echo "News Posted"; ?> Link to comment https://forums.phpfreaks.com/topic/57011-time-and-resgister-problem/#findComment-281647 Share on other sites More sharing options...
teng84 Posted June 25, 2007 Share Posted June 25, 2007 if(isset($_POST['submit'])) { mysql_query("INSERT INTO `news` (`user`, `subject`, `news`, `date`) VALUES ('".$user."','".$subject."','".$news."',now())"); } try that coding style and use isset and you also forgot the terminator what blank? Link to comment https://forums.phpfreaks.com/topic/57011-time-and-resgister-problem/#findComment-281649 Share on other sites More sharing options...
L Posted June 25, 2007 Author Share Posted June 25, 2007 when i said blank i meant the page showed up with nothing on it. And also it didn't work...the time is still ahead by one hour....and it is in 24 hour mode, i want it in 12 hour mode with an AM/PM, how would i do this? Link to comment https://forums.phpfreaks.com/topic/57011-time-and-resgister-problem/#findComment-281668 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.