Jump to content

News Article Page


wizzkid

Recommended Posts

So far this is the only code I have for now. I still dont have the code for comments.

 

=======

html

=======

<?php

include_once ('post_news.php');

?>

 

<form Action="add_news.php" Method="post">

<input name="postdate" type="text" id="postdate">

<input name="title" type="text" id="title">

<textarea name="newstext" cols="60" rows="15" id="newstext"></textarea>

<input type="submit" name="submit" value="Submit">

<input type="reset" name="reset" value="Reset">

</form>

 

==============

php - post_news.php

==============

<?php 

 

ini_set ('display_errors', 1);

error_reporting (E_ALL & ~E_NOTICE);

 

if (isset ($_POST['submit']))

 

{

 

require_once ('inc/dbConfig.php');

 

// Define the query.

$query = "INSERT INTO news (id, postdate, title, newstext) VALUES

(0,'{$_POST['postdate']}', '{$_POST['title']}','{$_POST['newstext']}')";

 

// Execute the query.

if (@mysql_query ($query)) {

print "<p>Data has been added.</p>";

} else {

print "<p>Could add the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>";

}

 

mysql_close();

 

}

 

?>

 

=====

db structure

======

id int(10) unsigned NOT NULL auto_increment,

  postdate timestamp(14),

  title varchar(50) NOT NULL,

  newstext text NOT NULL,

  PRIMARY KEY (id),

  KEY postdate (postdate)

 

 

Thanks a lot for your help guys! :)

 

Link to comment
https://forums.phpfreaks.com/topic/214623-news-article-page/#findComment-1116771
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.