Jump to content

[SOLVED] Sending post data using a hyperlink


MmmVomit

Recommended Posts

This is more of an HTML question.

 

I know how to send GET and POST data using a form.  I can also send GET data by simply appending it to the URL of a hyperlink, like so:

 

<a href="somepage.php?pageid=12345">link</a>

 

Is there some way to send POST data using a hyperlink?

Link to comment
Share on other sites

Yes and No. You cannot have an standard link tag (<a href=...) that would include POST data with a basic tag.

You could have something like this:

 

<form action="postdata.php" method="post">
<input type="hidden" name="pdata" value="this is my POST data">
<input type="submit" value="My POST page">
</form>

 

That works, but it isn't a link. However, this example does the same thing, but uses javascript to use a link.

 

<html>
<head>
<script language=javascript>
function submitPostLink()
{
document.postlink.submit();
}
</script>
</head>
<body>
<form action="postdata.php" name=postlink method="post">
<input type="hidden" name="pdata" value="this is my POST data">
</form>
<a href=# onclick="submitPostLink()">My POST page</a>
</body>
</html>

 

Should work.

 

EDIT: HTML Syntax

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.