Jump to content

[SOLVED] POST variable in link


leonglass

Recommended Posts

Thats great and so quick. I noticed that nothing past the "=" sign shows up when the link is hovered on. Is that linking to a page named delete. I tried it like this:

<a href=\"http://localhost/forum/forum.php={$_POST['somePostVar']}\">Delete</a>"

with and without the "=" and also removed the ".php" but no luck. Could you explain it a bit more for me please.

Oops, I forgot the '?' that would indicate we're creating a get parameter.

 

  $link = "<a href=\"http://localhost/forum/forum.php?var={$_POST['somePostVar']}\">Delete</a>";

 

Of course for this to work there has to be a value inside of $_POST['somePostVar'].

 

On the page in the link (forum.php in this case), to access the value you'd use:

 

echo $_GET['var'];

$_POST variables are available from form posts.  $_GET variables are available from the URL.  So AFAIK you can't directly do it.

 

You could place it in the URL and at the top of the script do:

 

$_POST['someVar'] = $_GET['someVar'];

 

and set the value manually if something in your script relies on it.

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.