Jump to content


Photo

Using $_GET


  • Please log in to reply
2 replies to this topic

#1 hanlonj

hanlonj
  • Members
  • PipPipPip
  • Advanced Member
  • 38 posts

Posted 03 October 2006 - 09:47 PM

I want to pass the value if a variable to another page by attaching it to the end of the href.

something like this:
<a href "nextPage.php?myValue='My Value'">Next Page</a>

I then want to grab it on the next page using like:

$msg = $_GET[myValue]

Then I want to print this value to the screen like:
echo $msg;

I can't seem to get it to work but I think it's just a small syntax problem. Can anyone give me a snippet example of how I would go about this please or point me in the right direction?

Thank you.

John



#2 thepip3r

thepip3r
  • Members
  • PipPipPip
  • Advanced Member
  • 289 posts

Posted 03 October 2006 - 09:50 PM

change $msg = $_GET[myValue] to $msg = $_GET['myValue'].  it should work this way. 

also, verify that the $_GET array is even seeing the variable passed.  use this function on the nextpage.php to see what's in the $_GET array:

echo "<pre>";
print_r($_GET);
echo "</pre>";


#3 MCP

MCP
  • Members
  • PipPipPip
  • Advanced Member
  • 60 posts

Posted 03 October 2006 - 11:59 PM

If your initial value is in PHP, you'll need to use something like:

<a href "nextPage.php?myValue=<?php echo urlencode($somevariable); ?>">Next Page</a>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users