HTTP Header not correct in PHP

67 views Asked by At

I have links that add a row to the database and then redirect to another page. In that page I want to show a message of success if it came from the insert page however the HTTP_REFERER doesn't acknowledge that page as the referer and instead shows the previous page.

So page-one.php contains a hyperlink:

http://example.com/add.php?c=359

and on add.php

header('Location: http://example.com/rows.php');

on rows.php I am expecting add.php to be the referer but it isn't instead page-one.php is.

How do I make add.php to be the referer cos that's where it is being redirected from?

1

There are 1 answers

0
dynamic On BEST ANSWER

The usual way it is with $_SESSION variables. Whenever you need to show a message add it:

$_SESSION['messages'][] = "your message";

Then, when you are on a page (any non-redirected page), show all of them and erase the content with:

$_SESSION['messages'] = array();