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 Quote Link to comment 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 Quote Link to comment 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']); Quote Link to comment 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 Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 24, 2007 Share Posted June 24, 2007 encryption or your md5 Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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"); ? Quote Link to comment 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())") Quote Link to comment 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"; ?> Quote Link to comment 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? Quote Link to comment 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.