Jump to content

Updating a pages content


wrathican

Recommended Posts

hey im using a form to update the content of a page on my website.

 

i have a table with 3 cols, id, title and content

a form with 3 fields. id(hidden), title(input) and content(textarea)

i have three pages that i want to be able to change the content and titles of.

 

here is the form:

<form name="editcont" action="/functions/adminfunctions.php?func=editpage" method="post">
	Page Title:<br />
	<input type="text" name="title" value="<?php echo $pageTitle; ?>" /><br />
	Page Content:<br />
	<textarea name="content" rows="15" cols="60"><?php echo $pageContent; ?></textarea>
	<input type="hidden" name="id" value="<?php echo $pageId; ?>" /><br />
	<input type="submit" name="edit" value="Edit" />
	</form>

 

and here is the processing script:

$id = $_POST['id'];
$title = $_POST['title'];
$content = nl2br($_POST['content']);

$query = "UPDATE won_content SET cont_title='".$title."', cont_content='".$content."' WHERE cont_id='".$id."'";
$result = query($query);

if($result) {

	//update was successful
	$_SESSION['errorstate'] = 1;
	$errorarray[] = "Thank you. The page you selected has been updated.";
	$_SESSION['errormessage'] = $errorarray;
	header('Location: ../admin/index.php');

}else{

	$_SESSION['errorstate'] = 1;
	$errorarray[] = "Sorry, but the page you tried to edit could not be edited right now. Please try again later.";
	$_SESSION['errormessage'] = $errorarray;
	header('Location: ../admin/index.php');

}

 

i can update pages 1 and 2, but the script throws my "Sorry, but the page you tried to edit could not be edited right now. Please try again later." error when i try an update page 3.

 

why is this happening?

Link to comment
https://forums.phpfreaks.com/topic/118343-updating-a-pages-content/
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.