How do I insert PHP code into a HTML Button? Here’s what I have:
<input type="submit" value="Buy" onclick="
<?php
$sq = mysql_query("SELECT * FROM accounts WHERE Username='$usr'");
$ar = mysql_fetch_array($sq);
if ($ar['Beevals'] >= 250){
mysql_query("UPDATE `accounts` SET `Beevals`=`Beevals`-250 WHERE Username='$usr'");
mysql_query("UPDATE `accounts` SET `Skin`=`WorkersDream` WHERE Username='$usr'");
}
?>
" />
But it doesn’t work. So, I’m wandering how exactly can you insert PHP code into a HTML Button?
“Inserting PHP into an HTML button” doesn’t make any sense. HTML is for the client’s browser, PHP executes on the server.
Take a look at the PHP tutorial to see a very basic example of how to make a form interact with PHP. To crib from there:
action.php