Jump to content

Archived

This topic is now archived and is closed to further replies.

hanlonj

Using $_GET

Recommended Posts

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

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

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

[code]$msg = $_GET[myValue][/code]

Then I want to print this value to the screen like:
[code]echo $msg;[/code]

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

Share this post


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

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

Share this post


Link to post
Share on other sites
If your initial value is in PHP, you'll need to use something like:

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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.