Page 1 of 1

Set a request value on a link

Posted: Thu Dec 20, 2007 2:38 pm
by gestes
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I am having issues with using the $_SESSION[...] as it is timing out. My app would work if I could do something like the following:

Code: Select all

<?php
  // This value may come from a database, or a $_REQUEST variable already
  $itemVal = "Value Alpha";

  // Set a link to call the new page with the $_REQUEST variable set for ?item
  echo "<a href='newPage.php?item=".$itemVal."'>Go to new page</a>";
?>
However, this does not seem to work as the ?item value is not showing up on the newPage.php being called.

What is the proper way to set a request variable for the target page?


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Thu Dec 20, 2007 4:09 pm
by Jonah Bron

Code: Select all

$str = "something";
echo '<a href="page.php?item='. $str .'">link</a>';
should give the output:
<a href="page.php?item=something">link</a>

It not working defies all logic. If it doesn't, the world has gone upside down. 8O

Re: Set a request value on a link

Posted: Fri Dec 21, 2007 12:57 pm
by Chalks
gestes wrote:

Code: Select all

<?php
  // This value may come from a database, or a $_REQUEST variable already
  $itemVal = "Value Alpha";

  // Set a link to call the new page with the $_REQUEST variable set for ?item
  echo "<a href='newPage.php?item=".$itemVal."'>Go to new page</a>";
?>
However, this does not seem to work as the ?item value is not showing up on the newPage.php being called.

What is the proper way to set a request variable for the target page?
Try using this:

Code: Select all

<?php
  // This value may come from a database, or a $_REQUEST variable already
  $itemVal = urlencode("Value Alpha");

  // Set a link to call the new page with the $_REQUEST variable set for ?item
  echo "<a href='newPage.php?item=".$itemVal."'>Go to new page</a>";
?>