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.

Link to comment
Share on other sites

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'];

Link to comment
Share on other sites

$_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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.