HTML Button, how to run php file with a parameter

Hi everyone,
My php code is consisted of 2 buttons as follows:

<!DOCTYPE HTML>
<html>
<body>
<button type="submit" onclick="myPHP.php/'1'">Click Me!</button>
<button type="submit" onclick="myPHP.php/'2'">Click Me!</button>
</body>
</html>

When user clicks left button I want the script to run “myPHP.php” with ‘1’ as a parameter, with
right button clicked I want “myPHP.php” to run with parameter ‘2’.
Is it possible to do?
Could anyone kindly explain me how?
Thanks

Why not just use a link rather than a button?

<a href="myPHP.php/1">1</a>
<a href="myPHP.php/3">2</a>
1 Like

This suggestion from @astonecipher is a better way of doing it and then just use CSS to style the link as a button.

1 Like

Thanks,
I guess i’ll forget about buttons till the day I learn js.

Sponsor our Newsletter | Privacy Policy | Terms of Service