Upon checking through the fourms I relized that the fourm I used should have been included in the newArticle.php file.
My newArticle.php:
Code:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<?php
// Get the PHP file containing the DbConnector class
require_once('../includes/DbConnector.php');
// Check whether a form has been submitted. If so, carry on
if ($HTTP_POST_VARS){
// Create an instance of DbConnector
$connector = new DbConnector();
// IMPORTANT!! ADD FORM VALIDATION CODE HERE - SEE THE NEXT ARTICLE
// Create an SQL query (MySQL version)
$insertQuery = "INSERT INTO cmsarticles (title,tagline,section,article) VALUES (".
"'".$HTTP_POST_VARS['title']."', ".
"'".$HTTP_POST_VARS['tagline']."', ".
$HTTP_POST_VARS['section'].", ".
"'".$HTTP_POST_VARS['article']."')";
// Save the form data into the database
if ($result = $connector->query($insertQuery)){
// It worked, give confirmation
echo '<center><b>Article added to the database</b></center><br>';
}else{
// It hasn't worked so stop. Better error handling code would be good here!
exit('<center>Sorry, there was an error saving to the database</center>');
}
}
?>
<body>
<table>
<form action="newArticle.php" method="post">
<tr>
<td>Title
</td>
<td><input type="textbox" name="title">
</td>
</tr>
<tr>
<td>Tagline:
</td>
<td><input type="textbox" name="tagline">
</td>
</tr>
<tr>
<td>Section
</td>
<td><input type="textbox" name="section">
</td>
</tr>
<tr>
<td>Article:
</td>
<td><input type="textarea" name="article" rows="20" cols="60"></textarea>
</td>
</tr>
</form>
</table>
</body>
</html>
the directory for newArticle.php is cmsadmin/newArticle.php.
After making these changes I now get this error when trying to access the newArticle.php page
Code:
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /data/www/net.athost.vhosts/r/robeysan.athost.net/public_html/includes/DbConnector.php on line 25
I try to access the page by typing the web address with cmsadmin/newArticle.php apended to the end.
www.exampl.com/cmsadmin/newArticle.php
What am I doing wrong?