Jump to content

quick question regarding the use of POST values and links


nikefido

Recommended Posts

I have so far only seen POST values used with form data / submit buttons - I'm assuming you can't make a regular link (aka anchor tag) send POST data when it is clicked?

 

The only solution I know would be to use JS to "AJAX" it (although you can set the JS function to send the info synchronously so it actually does reload the page!)

Link to comment
Share on other sites

Actually, if i'm understanding your question, using 'POST' creates an array of the form data that can be manipulated in the form processing code. If you want to pass parameters via the url then you would use 'GET' to snag the info and use it. Like this:

 

www.yoursite.com/page.php?memberid=333

 

Then use:

 

$memberid = $_GET['memberid'];

 

To do things like:

 

echo $memberid;

 

of insert into database, extract from database based upon that id, etc. etc. etc.

Link to comment
Share on other sites

Actually, if i'm understanding your question, using 'POST' creates an array of the form data that can be manipulated in the form processing code. If you want to pass parameters via the url then you would use 'GET' to snag the info and use it. Like this:

 

www.yoursite.com/page.php?memberid=333

 

Then use:

 

$memberid = $_GET['memberid'];

 

To do things like:

 

echo $memberid;

 

of insert into database, extract from database based upon that id, etc. etc. etc.

 

right, i know all this - i guess i was just wondering if you could use POST with a regular anchor (link) somehow - which I've assumed is "no" - but never hurts to ask, right?

Link to comment
Share on other sites

Well, in a way you can. Not using the typical <a href> tag, though. You would use it in your 'action' tag in the form:

 

action="nameofpage.php?memberid=$_POST['memberid']"

 

which would pass along the data. You can string as many items as you wish on the end of your url.

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.