Jump to content


Photo

GET without form


  • Please log in to reply
4 replies to this topic

#1 leedude

leedude
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 24 July 2006 - 04:43 PM

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

#2 Joe Haley

Joe Haley
  • Members
  • PipPipPip
  • Advanced Member
  • 103 posts
  • LocationCanada, eh?

Posted 24 July 2006 - 04:49 PM

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.
Give a man a fish; you have fed him for today.  Teach a man to fish; and you have fed him for a lifetime
Don't teach men to program. Teach them to fish.

Please, try the RTFM solution before asking for help:
http://php.net/manual/en/index.php

#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 24 July 2006 - 04:50 PM

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

Ken

#4 leedude

leedude
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 24 July 2006 - 06:53 PM

thanks.
Just wondering: is there a way to do it with post?

#5 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 24 July 2006 - 07:02 PM

use sessions instead. That way as long as the browser is open the variable can be used.

Ray




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users