spacepoet Posted April 14, 2011 Share Posted April 14, 2011 Hi: Can anyone tell me why the following is not working: a_Photo_Delete.php <?php $photo_id = $_REQUEST['photo_id']; mysql_query("DELETE FROM gallery_photos WHERE photo_id = $photo_id"); header("Location: a_Photo_Edit.php"); ?> <!DOCTYPE HTML> <html> <head> <meta charset="ISO-8859-1" /> <title></title> </head> <body> </body> </html> ------------------------------ a_Photo_Edit.php <p> <?php if ($_REQUEST['URL'] == 'a_Photo_Delete.php') { echo "<span class=\"textError\">Photo successfully deleted!</span>"; } ?> </p> The photo gets deleted OK, and the HEADER goes to the "a_Photo_Edit.php" page properly, but the "Photo successfully deleted!" message does not show up .. Confused why .. ?? Link to comment https://forums.phpfreaks.com/topic/233685-_requesturl-not-working/ Share on other sites More sharing options...
monkeytooth Posted April 14, 2011 Share Posted April 14, 2011 Because your redirecting the page before it has a chance to actually output that.. with header("Location")....... Link to comment https://forums.phpfreaks.com/topic/233685-_requesturl-not-working/#findComment-1201450 Share on other sites More sharing options...
kenrbnsn Posted April 14, 2011 Share Posted April 14, 2011 No, the location in the header goes to a different URL. The reason the message isn't showing up is that you're not passing any value via the URL, so there's nothing in the $_REQUEST['URL']. You probable want to use $_SERVER['HTTP_REFERER']. Echo it first to see what it is. Or put a value on the URL in the header: <?php header("Location: a_Photo_Edit.php?URL=a_Photo_Delete.php"); exit(); ?> Ken Link to comment https://forums.phpfreaks.com/topic/233685-_requesturl-not-working/#findComment-1201473 Share on other sites More sharing options...
spacepoet Posted April 14, 2011 Author Share Posted April 14, 2011 Hi, I tried it like this: <p> <?php if ($_SERVER['HTTP_REFERER'] == 'a_Photo_Delete.php') { echo "<span class=\"textError\">Photo successfully deleted!</span>"; } ?> </p> but it still doesn't work. I'm stumped because I took the code from another site, and it works fine on that one. Odd .. any other ideas? Thanks. Link to comment https://forums.phpfreaks.com/topic/233685-_requesturl-not-working/#findComment-1201613 Share on other sites More sharing options...
kenrbnsn Posted April 14, 2011 Share Posted April 14, 2011 Did you check to see what's in $_SERVER['HTTP_REFERER']? <?php echo '<pre>' . print_r($_SERVER,true) . '</pre>'; ?> It's very unlikely that the other site worked fine with that code. Ken Link to comment https://forums.phpfreaks.com/topic/233685-_requesturl-not-working/#findComment-1201631 Share on other sites More sharing options...
spacepoet Posted April 14, 2011 Author Share Posted April 14, 2011 I do know the other site has a QueryString, so maybe that's why it worked? <?php $photo_id = $_REQUEST['photo_id']; mysql_query("DELETE FROM gallery_photos WHERE photo_id = $photo_id"); header("Location: a_Page.php?myID=1"); ?> So, it will not work the way I have it? Thanks for the help. Link to comment https://forums.phpfreaks.com/topic/233685-_requesturl-not-working/#findComment-1201642 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.