I need to replace a button on my web page with a hyperlink. I am calling a PHP script using the button.
I extract the id using the following statement:
$id = $_POST['id'];
HTML code:
<form id='test1' method='post' action='my.php?action=show'> <input type='hidden' name='id' id='id' value='1' /> <input type='submit' name='submit' value='Click' onclick='return display(1);' /> </form>
Here is what I came up with:
<a href='my.php?action=show&id='1'' onclick='return display(1);'> Click</a>
Does my code have a flaw? Is there a better approach?
Looks good, except for three things:
&instead of&.id=1instead ofid='1'.$_GETinstead of$_POST. If you want backwards compatibility, you can opt for$_REQUEST.