March 27, 2011

convert this link to POST mode

Question by homlyn

How can I convert this $_GET method to $_POST method?

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

Answer by Starx

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

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!