Set a request value on a link

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gestes
Forum Newbie
Posts: 5
Joined: Thu Dec 13, 2007 12:46 pm

Set a request value on a link

Post 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]
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Post 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
User avatar
Chalks
Forum Contributor
Posts: 447
Joined: Thu Jul 12, 2007 7:55 am
Location: Indiana

Re: Set a request value on a link

Post 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>";
?>
Post Reply