Jump to content

requesting values


i8grand

Recommended Posts

Is there a way I can request a value from a previous page on a website with having to post it.  I have created a value $puzzle on a page on my website and am looking to use it on the next page when a user clicks a link to that page!  Is it just a matter of using REQUEST[$puzzle]?

 

I am relatively new to PHP and any help at all would be brilliant, thanks.

 

Dylan

Link to comment
https://forums.phpfreaks.com/topic/202767-requesting-values/
Share on other sites

A few methods.

You could use $_GET, which retrieves values from URLS.

E.g.

http://fake.url.com/page.php?foo=bar&id=12

$_GET['foo'] would be 'bar'

$_GET['id'] would be 'id'

This would have to be set in the links to that page though for it to work.

 

You could also use a SESSION or set a COOKIE.

 

Related example:

 

The previous page.

session_start();
...
$_SESSION['puzzle'] = "foo";
...

 

And on the other page.

session_start();
...
echo $_SESSION['puzzle'];
...

 

Of course, you can do anything with the retrieved session. Same applies with cookies.

 

 

Hope I've helped :).

Link to comment
https://forums.phpfreaks.com/topic/202767-requesting-values/#findComment-1062723
Share on other sites

Archived

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

×
×
  • Create New...

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.