Ashish GamezAddicted
Ashish GamezAddicted

Reputation: 93

php conditional internal redirect after script execution

I have 3 files index.php, search.php, test.php

test.php contains a script just for execution doesn't display anything I want user to automatically redirect (without delay, without displaying anything) from test.php (after execution of test.php) to where they came from

like this

index.php -> test.php ---> index.php

search.php?q=searchterm -> test.php ---> search.php?q=searchterm

I'm new to php so help anyone

Upvotes: 0

Views: 700

Answers (2)

kryoz
kryoz

Reputation: 87

Any "redirect" is implemented by sending HTTP request. You have to make sure that no output was before sending headers.

    header ('HTTP/1.1 301 Moved Permanently');
    header ('Location: '.$location);

where $location = 'http://yoursite.com/destination.php'; for example. You can also send headers with GET or POST parameters if you want. See php POST variable with headers

Upvotes: 1

jackjack
jackjack

Reputation: 1

use header( "refresh:3;url=any page you want" );

Upvotes: 0

Related Questions