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 post
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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...