Help - Search - Members - Calendar
Full Version: [resolved] Taking out Auto Refresh on Update
Codegrrl.com Forums > Script Help > Tutorial Help
Sairah
The header files in my update page were in conflict for some reason so, after trying all the solutions on the forums, it still didn't work [for me, anyhow], so I decided to just get rid of the redirect to the single entry page. However, when I do this, I still get an "Invalid entry ID" error.

I'm taking out this part here:

CODE
  header("Location: blog_Update.php?id=" . $id);


In the tutorial, it said this was what would take us to the single entry page so that we could view the changes, but I don't need that bit. Anyway to take it out without getting the error?

Thanks a million in advance! =D
Neuriel
The reason you are getting this error is because by taking out that line, when you update a post, it goes to edit.php. However, edit.php requires an id to be set or it will show that error.


Here is how I would do it. Open up the file you use to edit an entry. Find this line and remove it.
CODE

<input type="hidden" name="id" value="<?php echo $id; ?>" />


Then find this line:
CODE

<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">


Change it to:
CODE

<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?id=<?php echo $id; ?>">


Find this line and remove it.

CODE

$id = htmlspecialchars(strip_tags($_POST['id']));


Add this instead:
CODE

if (!isset($_GET['id']) ||empty($_GET['id']) || !is_numeric($_GET['id'])) {
    die("Invalid entry ID.");
}
else {
    $id = (int)$_GET['id'];
}


And you're done. I know of a more simple way but I'm not sure in terms of its security.
Sairah
Wow, thanks, I will go ahead and try it, pronto! ^__^

[UPDATE] It works fine, thanks for the script, however, I have another measly request...

I was hoping I could get it to print a small "Entry successfully edited" or something at the top? Is there any way to do this? Still, the lack of autorefreshing is helpful to me, I find it a bit superfluous, so thanks for that one once agian. ^^

[EDIT] Nevermind on that request, I fiddled with it myself. =D
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.