i have section tag value updated based on user clicks package in page1.php
. i.e nothing selected, section tag have nothing in it, user selects package 1 section tag because package 1. when use php post
, check if set not there reason this?
i want post_['foodchoice']
set can have section in page2.php
can summarize packages user have selected.
sort of shopping cart functionality no database, quantity selections etc. please advise why. thanks
page1.php
<script type ="text/javascript"> function changemybutton() { var elem = document.getelementbyid("button3"); if (elem.value == "un-select package") elem.value = "select package"; else if( elem.value == "package selected!" ) { elem.value = "select package"; elem.style.background = "#003e7e"; document.getelementbyid("selection").innerhtml = ''; } else { elem.value = "package selected!"; elem.style.background = "green"; document.getelementbyid("selection").innerhtml = '1x share collection'; } } </script> <h1 id="logo"> breakfast menu options </h1></section> <hr> </br> <center> <form action="homepage.php" method="post" onsubmit=""> <center> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"> </script> <div class= "breakfast"> <u><h2>the share collection</h2></u> </br> <img src= "\images\breakfast\breakfast1.jpg" class="funky"> </br> </br> <dl> <dd>mini jar of housemade granola: vanilla yoghurt, fresh fruit (v) (6)</dd> <dd>goat cheese, cherry tomato & basil, mushroom tart (v) (8)</dd> <dd>mini slider jamon serrano, fig jam, rocket, brie & black pepper (8) </dd> <dd>chef's mini sweet muffin (v) (8)</dd> <dd>bowl of strawberries & grapes (v) (1)</dd> </dl> </br> <input type='button' value='select package' id='button3' onclick="changemybutton()"> <hr> <section id="myform"> <h1 id="logo">total ordered</h1></section> <hr> </br> <section id ="selection" name="foodchoice"></section> <br> <br> <br> <br> <input type="button" id="button4" value="submit selection" name="submit" onclick="window.location='homepage.php';" > </div> </center> </form> </div> </div>
page 2.php
<?php session_start(); error_reporting( e_all & ~e_notice ); if (!isset($_session['time'])) { header("location: openingpage.php"); exit(); } if (isset($_post['foodchoice'])) { echo "yay!"; } if (!isset($_post['foodchoice'])) { echo "nay!"; } ?>
then within html body have:
<div id ="packageselected"> <?php echo $_post['foodchoice']; ?> </div>