开发者

convert this link to POST mode

How can I convert this $_GET method to $_PO开发者_JAVA技巧ST method?

$linkword .= "\n<A HREF=\"$self?letters=$alpha[$c]$letters&n=$n\">$alpha[$c]</A> ";


You cannot pass $_POST data in a url, you must use cURL (PHP), AJAX (javascript), or a similar tool to build full HTTP requests.

ALTERNATE SOLUTION

You could however build a small form that submits, but you would have to use a submit button control for the "link" and use some hidden form inputs. You can Re-style the button anyway you wish with CSS.

<form action="link/url.php" method="post">
    <input type="hidden" name="letters" value="value of letters" />
    <input type="hidden" name="n" value="value of $n" />
    <input type="submit" value="text of button" name="submit" />
</form>


You cannot POST data using URL Parameters. You will have to use a form with a method set to POST. Then submit the form on clicking the link or use a button.

Solution would be to use hidden form elements for your params and submit the hidden form when your click on the anchor tag.

Another solution would be to use ajax to post data. If you use jQuery or some libraries, you can do so.


Instead of creating a anchor tag. Create a hidden form

$linkword .= "\n<A HREF=\"$self?letters=$alpha[$c]$letters&n=$n\">$alpha[$c]</A>";

Here is a Sample

<form name="hiddenform" method="POST" action="page.php">
   <input type="hidden" name="letters" value="<? echo alpha[$c].$letters; ?>" />
   <input type="hidden" name="n" value="<? echo $n; ?>" />
   <a onclick="document.forms['hiddenform'].submit();">Test Link <? echo $alpha[$c]; ?></a>
</form>

Jsfiddle Demo

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜