Jump to content

Simple News System


driz

Recommended Posts

Hi,I'm building a simple news system that will allow someone to go to say post.php and then add some data and then it will be uploaded to a database.These are the fields: ID, Title, Date/Time, Body, Excerpt, ImageMost of these will be very simple to do, basic text boxes etc, but the date/time needs to be automatic, so that when the user submits the post and its uploaded, the date/time is automatically added, can anyone point me in the right direction as to how I could do this, thanks.

Link to comment
Share on other sites

Hi,I'm building a simple news system that will allow someone to go to say post.php and then add some data and then it will be uploaded to a database.These are the fields: ID, Title, Date/Time, Body, Excerpt, ImageMost of these will be very simple to do, basic text boxes etc, but the date/time needs to be automatic, so that when the user submits the post and its uploaded, the date/time is automatically added, can anyone point me in the right direction as to how I could do this, thanks.
i all ways do this
<?php$date = date("m.d.y");mysql_query("INSERT INTO table (date) VALUES({$date}");?>

Link to comment
Share on other sites

This is my process code:

<?php							$title=$_POST['title'];		$date=date("m.d.y");		$body=$_POST['body'];		$excerpt=$_POST['excerpt'];		$image=$_POST['image'];		$host='localhost';		$username='u0558234';		$pass='26jun87';		mysql_connect($host,$username,$pass);		mysql_select_db($username);		$query="INSERT INTO news VALUES (NULL,'".$title."','".$date."','".$body."','".$excerpt."','".$image."')";		$result=mysql_query($query);		if(mysql_affected_rows()==1) {			echo 'details were successfully added';			}		else		{		echo 'there was a problem';	}?>

Will that work?

Link to comment
Share on other sites

	$query=\"INSERT INTO news VALUES (NULL,\'\".$title.\"\',\'\".$date.\"\',\'\".$body.\"\',\'\".$excerpt.\"\',\'\".$image.\"\')\";	

im not sure about this line the rest should work if you don\'t have an index problem .it looks wrong.

$result=mysql_query($query);

that wont work with insert make a new query with select

   if(mysql_affected_rows()==1)  

what are you trying to do here ?edit 1-2 i didn\'t see these right awayedit 3 you should add some securityedit 4 you can add h:i:s in date like this

$date = date("m,d,y h:i:s")

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...