Jump to content

Photo on news article


wizzkid

Recommended Posts

Hello,

 

can you help me on my news article?

I would like to be able to add photo on the article. Below is my codes

 

=======

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)

 

Hope you guys can help me.

 

Thanks!

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.