Jump to content

MY FORM WONT LOAD FOR ME TO EDIT


jlifeman211

Recommended Posts

I HAVE TRIED looking at it  but i am new to php so i can't figure out what i did wrong  help plz !!!!!!!!!!!!

 

 

 

 

Fatal error: Call to undefined method modernCMS::update_form() in C:\wamp\www\test\inc\update-content.php on line 4

 

----

Page that's accessing code

-----

<?php

 

include '../test/inc/admin/nav.php';

echo $obj->update_form($_GET['id']);

 

?>

 

------

function

------

 

<?php

 

class modernCMS {

 

var $host;

var $username;

var $password;

var $db;

 

function connect() {

$con = mysql_connect($this->host, $this->username, $this->password) or die(mysql_error());

mysql_select_db($this->db, $con) or die(mysql_error());

 

} //end connect

 

function get_content($id = '') {

 

if($id != ""):

$id = mysql_real_escape_string($id);

$sql = "SELECT * FROM cms_content WHERE id = '$id'";

 

// $return = "<p><a href=../test/inc/admin/nav.php>Go Back To Content</a></p>";

 

else:

$sql = "SELECT * FROM cms_content 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 '<table bgcolor="#975627" width="100%" border="0" cellspacing="1" cellpadding="3">

<tr>

<td height="25" background="images/menu.gif"><center><strong>' . $row['title'] . '</strong></center></td>

 

</tr>

<tr bgcolor="975627"><td height="0"></td></tr>

 

<tr>

<td bgcolor="#181818">

';

echo '<br>

<div align="center">' . $row['body'] . ' <br><br>

</td>

 

</tr>

 

<tr>

<td height="25" background="images/menu.gif">

</td>

 

</tr>

 

</table><br><br>

';

}

else:

echo '<p>Uh Oh!!! </p>';

endif;

 

// echo $return;

 

 

} //end get_content

 

function add_content($p) {

$title = mysql_real_escape_string($p['title']);

$body = mysql_real_escape_string($p['body']);

 

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

 

if(!$title):

echo "<p>The title is required!</p>";

endif;

if(!$body):

echo "<p>The body is required!</p>";

endif;

 

echo '<p><a href="add-content.php">Try Again!!!</a></p>';

 

else:

$sql = "INSERT INTO cms_content VALUES (null, '$title', '$body')";

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

echo "Added Successfully!";

endif;

} //end add_content

 

function manage_content() {

$sql = "SELECT * FROM cms_content ORDER BY id DESC";

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

while($row = mysql_fetch_assoc($res)):

 

?>

 

<div>

<h2 class="title"><?php echo $row['title']; ?></h2>

<span class="actions"<a href="../test/update-content.php?id=<?php echo $row['id']?>">Edit</a> | <a href="?delete=

 

<?php

 

echo $row['id']

 

?>

 

">Delete</a></span>

</div>

 

<?php

endwhile;

echo '</div>'; //Class Manage Div

 

} //end manage_content

 

function delete_content($id) {

if(!$id) {

return false;

}else {

$id = mysql_real_escape_string($id);

$sql = "DELETE FROM cms_content WHERE id = '$id'";

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

echo "Content Deleted Successfully!";

}

}

} //end delete_content

 

function update_form($id) {

$id = mysql_real_escape_string($id);

$sql = "SELECT * FROM cms_content WHERE id = '$id'";

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

$row = mysql_fetch_assoc($res);

 

?>

 

<form method="post" action="./post-added.php">

 

<input type="hidden" name="update" value="true" />

<input type="hidden" name="id" value="<?php $row['id'] ?>" />

 

<div>

<label for="title">Title:</label>

<input type="text" name="title" id="title" value="<?php echo $row['title'] ?>" />

</div>

 

<div>

<label for="body">Body:</label>

<textarea name="body" id="body" rows="8" cols="40" /><?php echo $row['body'] ?></textarea>

</div>

 

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

 

</form>

<?php

 

} //end update_content_form

 

function update_content($p) {

$title = mysql_real_escape_string($p['title']);

$body = mysql_real_escape_string($p['body']);

$id = mysql_real_escape_string($p['id']);

 

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

 

if(!$title):

echo "<p>The title is required!</p>";

endif;

if(!$body):

echo "<p>The body is required!</p>";

endif;

 

echo '<p><a href="update-content.php?id=' . $id . '">Try Again!!!</a></p>';

 

else:

$sql = "UPDATE cms_content SET title = '$title', body = '$body' WHERE id = '$id'";

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

echo "Updated Successfully!";

endif;

} //end update_content($p)

 

 

 

?>

Link to comment
https://forums.phpfreaks.com/topic/223743-my-form-wont-load-for-me-to-edit/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.