My project is a menu that displays daily specials at a cafe. The Pointy Haired Boss(PHB) needs to add/remove items from the menu on a daily basis,
so I stored all dishes with MySQL, and created a page which will load all menu items as buttons. When clicked, the button will UPDATE the item, turning it on or off.
I need form data to detect which button was pressed, so my query knows which $menuItem to UPDATE. That is the purpose of the hidden fields.
<html><head></head>
<body>
<html><head></head>
<body>
<?php include("getElement.php");
$keys = array_keys($_POST);
echo $keys[0];
echo $keys[1];
//if(isset($_POST["menuItem"])){
//toggleItem($_POST["menuItem"]);
//echo print_r(array_keys($_POST));}
?>
<form name="b" action="scratchpad.php" method="post" >
<input type="hidden" name="b" value="Cajun Gumbo"/>
<input type="submit" style="color:blue" value="Cajun Gumbo" /> </form>
<form name="a" action="scratchpad.php" method="post" >
<input type="hidden" name="a" value="Guacomole Burger"/>
<input type="submit" style="color:blue" value="Guacomole Burger" /> </form>
</body>
</html>
Can I get $_POST to identify which button was pressed? I get this error: Undefined offset: 1 in /home/ubuntu/public_html/scratchpad.php on line 10