Jump to content

Time and resgister problem


L

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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