Problem with cms
Hi,
I'm building a cms using php and mysql and have a page called createarticle.php which has the following form:
<form action='processnewarticle.php' method='post'>
<p>Title</p>
<input type=text name='title'>
<p>Description</p>
<input type=text name='description'>
<p>Your Article</p>
<textarea name='article' rows=5 cols=62></textarea>
<input type=submit value='Submit Form'> <input type=reset value='Reset Form'>
</form>
My processnewarticle.php page has the following code to make it enter the form information into the database:
<?php
require_once('dbconnect.php');
if ($_POST){
$connector=newDbConnector();
$insertQuery = "INSERT INTO article (title,description,article) VALUES ("."'".$_POST['title']."',".
"'".$_POST['description']."',".
"'".$_POST['article']."')";
if ($result = $connector->query($insertQuery)){
echo 'Article sucessfully added to database. Please <a href="controlpanel.php">click here</a> to return to the control panel home page.';
}else{
exit('Sorry, but there was an error submitting your article to the database, please contact your support operator through the more link on the left');
}
}
?>
However, when I submit my article through my form it goes to processnewarticle.php but just comes up blank and doesn't put the info into the db???
Has anyone got any ideas why? I've included the mysql query for the article table below. If anyone could shed some light on where I've gone wrong, that'd be great.
CREATE TABLE article(
ID int(6) UNSIGNED NOT NULL AUTO_INCREMENT,
title varchar(200) NULL,
description varchar(255) NULL,
article text NULL,
PRIMARY KEY (ID)
);
Thanks
hs1984
|