Reputation: 24481
I have a php script which can take some GET params. I would like to know how I can call the script with a different param inside the script.
I want to achieve something like this:
if ($param == "authorise") {
//call the same script but use the $param, getAccountDetails"
i.e http://mywebsite.com/?param=getAccountDetails&var=ivar&foo=bar
}
Upvotes: 0
Views: 86
Reputation: 15905
The simplest thing I can think of would be to redirect the user to the script with the new GET variable.
if( $_GET['abc'] == 1 ) {
header( 'Location: '.$_SERVER['PHP_SELF'].'?abc=2' );
}
If you would like to do this without exiting the running PHP script, take a look at cURL.
Upvotes: 0
Reputation: 437
Use sessions
http://php.net/manual/en/features.sessions.php
sessions are used to add information to the client so they can be retrieved later.
Upvotes: 0
Reputation: 28205
You could just modify the $_GET array at the top of the script depending on what's inside it:
if(isset($_GET['authorise'])){
$_GET['do_some_secret_thing'] = 'whatever';
}
// run the rest of your logic LIKE A BOSS.
There might be some more wizardy way of doing it, but that'd work and is fairly straightforward.
Good luck!
Upvotes: 1