Jump to content

Passing Paramater via PHP call


Recommended Posts

I tried that but I end up with the value of my $getmyparam being equal to "myparam" instead of the value passed which in my  test case is "10006"

In my calling function, I confirm the value of "myparam" and it is "10006".


function ancesterF(myparam)
{alert(myparam);  <----------------------------------------------------------------------------------This confirms the value "10006"
location.href='FT_Search2.php?param=myparam';return false;
window.open(location.href); return false;}



$getmyparam =$_GET['param'];

print("getmyparam");  <------------------------------- Result = "myparam"  not "10006"


Link to comment
Share on other sites

  • 4 weeks later...

Hello, @mickeymouse

Please try this code for passing parameter into URL and to get parameter in current page and also for redirected page.

To get parameter value in current page use this code :

$url = 'http://www.geeksforgeeks.org/register?name=Demo&email=demo@gmail.com'; 
$url_components = parse_url($url); 
parse_str($url_components['query'], $params); 
echo ' Hi '.$params['name'].' your emailID is '.$params['email']; 

To get parameter value for redirected page use this code :


$name = $_REQUEST['name'];
$email = $_REQUEST['email'];

echo " Hi ".$name." your emailId is ".$email;


For both code output will be :

Hi Demo your emailId is demo@gmail.com

I hope above information will be useful for you.
Thank you.

Link to comment
Share on other sites

I'm using the following according to dsonesuk advice and it works fine..

To pass the parameter:

function ancester(myparam)
{if(myparam==''){return false;}
location.href='FT_Search2.php?param='+myparam;return false;
window.open(location.href); return false;}

To get the parameter:


Thanks for the help!


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...