Jump to content

Archived

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

leedude

GET without form

Recommended Posts

Is there some way to make send a GET or POST variable like a session variable, without using a field.
Something like this:
[code]
<?php
$_GET['data'] = "hello";
echo "<a href = "page2.php">page 2</a>";
?>
[/code]
Would produce: 86.131.190.81/page2.php?data=hello
Usually i have to use a hidden field, which can get very tedious.

Share this post


Link to post
Share on other sites
Do you mean passing variables via the get method in a hyperlink?

If so:

echo '<a href="page2.php?var=' . $val . '">';

On page2.php:

$_GET['var'] would contain the value of $val.

Share this post


Link to post
Share on other sites
For parameters on the URL, you can just create the URL with those parameters, which then are recieved in the $_GET array:
[code]<?php echo '<a href="page.php?data=hello">Page 2</a>'; ?>[/code]

Ken

Share this post


Link to post
Share on other sites
use sessions instead. That way as long as the browser is open the variable can be used.

Ray

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.