Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $inventory = array('milk', 'cheese', 'bread', 'soda', 'weed');
- if(isset($_POST['submit'])) {//if form is submitted
- if (!in_array($_POST['order_txt'], array_keys($inventory)))
- {
- //item # specified wasn't in the list
- }
- else
- {
- $_SESSION['items'][] = $inventory[$_POST['order_txt']];
- }
- }
- var_dump($_SESSION);
- echo "Welcome to Food Mart."."<br/><br/>";
- echo "We carry the following items: "."<br/>";
- for($x=0; $x<sizeof($inventory); $x++){
- echo $x . ":" . $inventory[$x]."<br/>";
- }
- echo "<br/>";
- ?>
- <html>
- <body>
- <form action="<?php echo $PHP_SELF;?>" method="post">
- Number of Item: <input type="text" name ="order_txt" />
- <input type="submit" name="submit" value="Place Order"/>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement