I have this code and it works.
echo "<input type='submit' name='liga' value='Liga'>";
if (isset($_POST['liga'])) {
unset($_POST['liga']);
liga();
?>
But I need change the name LIGA to the php variable $on. I tried this but don't work.How can I insert the variable in this code?
$on=1;
echo "<input type='submit' name='$on' value='Liga'>";
if (isset($_POST['$on'])) {
unset($_POST['$on']);
liga();
}
?>
The problem here is that variables inside single quotes don't get interpolated whereas variables inside double quotes do.
echo "<input type='submit' name='$on' value='Liga'>";
becomes
<input type='submit' name='1' value='Liga'>
But $_POST['$on']
stays the same. To solve this, use $_POST[$on]
(or the equivalent $_POST["$on"]
).