Jump to content

[SOLVED] date() errors.


Noskiw

Recommended Posts

<?php

$connect = mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("blog", $connect) or die(mysql_error());

if(!$_POST['submit']){
echo "

<form action='index.php?p=blog&p=admin' method='POST'>

<table width='100%'>

<tr>

<td width='9%' valign='top'>
Your Name:
</td>

<td valign='top'>
<input type='text' name='name' maxlength='25' />
</td>

</tr>

<tr>

<td valign='top'>
Your Email:
</td>

<td>
<input type='text' name='email' maxlength='35' />
</td>

</tr>

<tr>

<td valign='top'>
Your Post:
</td>

<td>
<textarea cols='50' rows='5' name='message' maxlength='250'></textarea>
<p><input type='submit' name='submit' value='Post' />
</td>

</tr>
</table>

</form>";
}else{

$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$date = date("Y-m-d");
    $time = date("H:i:s");  

if($name && $email && $message){
	$querypost = mysql_query("INSERT INTO blog VALUES('','" . $name . "','" . $email . "','" . $message . "','" . $date . "','" . $time . "')");
	echo "<hr />Please wait... <meta http-equiv='refresh' content='2'>\n";
	echo "Successfuly posted!";
}
}

?>

 

This is my code for posting the blog entry.

 

But unfortunately, the date and time are inputted wrong.

 

It looks like

 

  time       date

00:20:09 0000-00-00

 

which is really starting toi p**s me off...  >:(

Link to comment
https://forums.phpfreaks.com/topic/178661-solved-date-errors/
Share on other sites

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.