Abu Nooh
Abu Nooh

Reputation: 856

HTTP Header not correct in PHP

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?

Upvotes: 0

Views: 62

Answers (1)

dynamic
dynamic

Reputation: 48091

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();

Upvotes: 1

Related Questions