undefined function [PHP] please help?

Tex0gen

New member
Im creating a CMS.. i keep getting undefined function, can someone help please? [attached]
Error on line 9 of this page:

<------------ index.php ---------------->

<?php
include '../cms_class.php';

$obj = new pbcms();

$obj->host = 'localhost';
$obj->username = 'web';
$obj->password = '*********';
$obj->db = 'web';
$obj->connect();

include('nav.php');

if($_POST['add']):
$obj->addcontent($_POST);
endif;
?>
<------------end index.php --------------->

<------------ add_content.php----------->

<form method="post" action="index.php">

<input type="hidden" name="add" value="true" />
<label for="title">Title:</label>
<input type="text" name="title" id="title" />
<label for="body">Body:</label>
<textarea name="body" id="body" rows="8" cols="20"></textarea>

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

</form>

<---- end add_content.php ----------->
<----------- cms_class.php --------------->
<?php

class pbcms {

var $host;
var $username;
var $password;
var $db;

function connect() {
$con = mysql_connect($this->host, $this->username, $this->password);
mysql_select_db($this->db, $con) or die(mysql_error());
}

function get_content($id = '') {

if($id != ""):
$id = mysql_real_escape_string($id);
$sql = "SELECT * FROM cmscontent WHERE id = '$id'";

$return = '<a href="/cms/index.php">Go Back To Content</a>';
else:
$sql = "SELECT * FROM cmscontent ORDER BY id DESC";
endif;

$res = mysql_query($sql) or die(mysql_error());

if(mysql_num_rows($res) !=0):
while($row = mysql_fetch_assoc($res)) {
echo '<h1><a href="/cms/index.php?id=' . $row['id'] .'">' . $row['title'] . '</a></h1>';
echo '<p>' . $row['body'] . '</p>';
}
else:
echo '<p>Nothing to Display</p>';
endif;

echo $return;

function addcontent($p) {
$title = mysql_real_escape_string($p['title']);
$body = mysql_real_escape_string($p['body']);

if(!$title || !$body):

if(!$title):
echo 'Title Required';
endif;
if(!$body):
echo 'Body Required';
endif;

echo '<a href="/admin">Try Again</a>';

else:
$sql = "INSERT INTO cmscontent VALUES (null, '$title', '$body')";
$res = mysql_query($sql) or die(mysql_error());
echo "Added Successfully";
endif;
}}

} //ends our class

?>


<------------- end of CMS_CLASS.PHP ------------>


It connects to the database and im able to get all table data but i want to POST table data from form.
 
Back
Top