Jump to content

Archived

This topic is now archived and is closed to further replies.

MmmVomit

[SOLVED] Sending post data using a hyperlink

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?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

That's great.  About what I expected, but I just didn't know how to do it.  Thanks.

Share this post


Link to post
Share on other sites

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