Fatal error: Call to a member function add_content() on a non-object
here is my index:
<?php
include ('lib/connect.php');
include('lib/nav.php');
if($_POST['add']):
$obj->add_content($_POST);
endif
?>
Here is my function:
<?php
function add_content($p) {
$title = mysql_real_eacape_string($p['title']);
$body = mysql_real_eacape_string($p['body']);
if(!$title || !$body):
if(!$title):
echo"The Title is required";
endif;
if(!body):
echo"The Body is required";
endif;
echo"<a href='add_content.php'>Try again</a>";
else:
$sql = "INSERT INTO content VALUES(null, '$title', '$body')";
$res = mysql_query($sql) or die (mysql_error());
echo"Added Successfuly!";
endif;
}
?>
here is my add_content.php:
<?php
include ('lib/connect.php')
?>
<html>
<head>
</head>
<body>
<form method="post" action="index.php">
<input type="hidden" name="add" value="true" />
<div>
<label for="title">Title: </label>
<input type="text" name="title" id="title" />
</div>
<div>
<label for="title">Title: </label>
<textarea name="body" id="body" rows="8" cols="40"></textarea>
</div>
<input type="submit" name="submit" value="Add Content" />
</form>
</body>
</html>
can some please give me some information of what i am doing wrong to keep getting this error