-2

I have a list of rows with their respective links to go to "remove.php" and run "DELETE FROM" and so remove each row separately.
This list is on a dynamic page details.php?recordID=123

How could I set the header(location: ...) value including the details.php parameters?
I want to go back (Reliably) to the source list after deleting the row.

  $deleteGoTo = "details.php?recordID=123";
  if (isset($_SERVER['QUERY_STRING'])) {
    $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
    $deleteGoTo .= $_SERVER['QUERY_STRING']; }
  header(sprintf("Location: %s", $deleteGoTo));

Thanks!

Drew McGowen
  • 11,471
  • 1
  • 31
  • 57
Ego
  • 1
  • 2
  • What exactly is the problem with your code? Do you get an error? – Michael Aug 02 '13 at 14:57
  • @Michael , If I put a valid page to `$deleteGoTo` there is no problem. Eg: `$deleteGoTo = "details.php"` So, everything works perfect. But I need to go to a dynamically generated list (page) containing parameters. Example: www.domain.com/details.php?recordID=123 At the moment I don't know how to pass the parameter `?recordID=123` I hope I have explained well, thanks. – Ego Aug 02 '13 at 16:50

1 Answers1

0

Checkout the parse_url and parse_str functions.

http://www.php.net/manual/en/function.parse-url.php

http://php.net/manual/en/function.parse-str.php

Mircea Soaica
  • 2,829
  • 1
  • 14
  • 25