Jump to content

$_REQUEST['URL'] not working .. ??


spacepoet

Recommended Posts

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

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

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.

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.

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.