How can I show my form values with php/javascript?

Discussion in 'HTML & Website Design' started by Sri Shame, Jan 22, 2015.

  1. #1
    Want to display the crust and toppings that the user has selected. want it to display the crust and toppings for the 1st pizza, crust and toppings for 2nd pizza and so on. any ideas of I can use php or javascript array to display what I want? Below is my order form.

    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Voglia Piazza - Order</title>
    <style>
        fieldset {
        border: 0;
    }
    </style>
    </head>
    
    <body>
    <!--
    <?php 
    print_r($_POST); 
    ?>
    -->
    <?php
    $crust = $_POST['crust'];
    ?>
        <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
        <h2>Crust</h2>
        <fieldset>
            <label for="crust">Pizza Crust</label>
            <select name="crust" id="crust">
                <option value="sgcrust">Singapore Crust</option>
                <option value="clsTcrust">Classic Thin Crust</option>
                <option value="nyccrust">New York Crust</option>
                <option value="chiccrust">Chicago Crust</option>
                <option value="cheesycrust">Cheesy Crust</option>
            </select>
        </fieldset>
        <h3>Toppings</h3>
        <fieldset>
        <legend>Classics</legend>
            <input type="checkbox" name="toppings[pepperoni]" id="toppings_pepperoni" />
            <label for="toppings_pepperoni">Pepperoni</label>
            <br />
            <input type="checkbox" name="toppings[sausage]" id="toppings_pepperoni" />
            <label for="toppings_pepperoni">Sausage</label>
            <br />
            <input type="checkbox" name="toppings[pineapple]" id="toppings_pineapple" />
            <label for="toppings_pineapple">Pineapple</label>
            <br />
            <input type="checkbox" name="toppings[peppers]" id="toppings_peppers" />
            <label for="toppings_peppers">Peppers&lpar;Combination of Red,Green, Yellow&rpar;</label>
            <br />
        </fieldset>
        <fieldset>
            <legend>Seafood</legend>
            <input type="checkbox" name="toppings[prawn]" id="toppings_prawn" />
            <label for="toppings_prawn">Prawn</label>
            <br />
            <input type="checkbox" name="toppings[squid]" id="toppings_squid" />
            <label for="toppings_squid">Squid</label>
            <br />
            <input type="checkbox" name="toppings[crab]" id="toppings_crab" />
            <label for="toppings_crab">Crab</label>
            <br />
            <input type="checkbox" name="toppings[mussels]" id="toppings_mussels" />
            <label for="toppings_mussels">Mussels</label>
            <br />
            <input type="checkbox" name="toppings[scallop]" id="toppings_scallop" />
            <label for="toppings_scallop">Scallop</label>
        </fieldset>
        <fieldset>
            <legend>Meat</legend>
            <input type="checkbox" name="toppings[chicken]" id="toppings_chicken" />
            <label for="toppings_chicken">Chicken</label>
            <br />
            <input type="checkbox" name="toppings[beef]" id="toppings[beef]" />
            <label for="toppings_beef">Beef</label>
            <br />
            <input type="checkbox" name="toppings[bacon]" id="toppings_bacon" />
            <label for="toppings_bacon">Bacon&lpar;Chicken/Turkey&rpar;</label>
            <br />
            <input type="checkbox" name="toppings[ham]" id="toppings_ham" />
            <label for="toppings_ham">Ham&lpar;Chicken/Turkey&rpar;</label>
         </fieldset>
         <fieldset>
             <legend>Vegetarian</legend>
            <input type="checkbox" name="toppings[onion]" id="toppings_onion" />
            <label for="toppings_onion">Onion</label>
            <br />
            <input type="checkbox" name="toppings[olive]" id="toppings_olive" />
            <label for="toppings_olive">Olive</label>
            <br />
            <input type="checkbox" name="toppings[corn]" id="toppings_corn">
            <label for="toppings_corn">Corn</label>
            <br />
            <input type="checkbox" name="toppings[mushroom]" id="toppings_mushroom">
            <label for="toppings_mushroom">Mushroom</label>
         </fieldset>
         <fieldset>
             <legend>Cheese</legend>
            <input type="checkbox" name="toppings[mozzarella]" id="toppings_mozzarella">
            <label for="toppings_mozzarella">Mozzarella</label>
            <br />
            <input type="checkbox" name="toppings[creamcheese]" id="toppings_creamcheese">
            <label for="toppings_creamcheese">Cream Cheese</label>
            <br />
            <input type="checkbox" name="toppings[provolone]" id="toppings_provolone">
            <label for="toppings_provolone">Provolone</label>
            <br />
            <input type="checkbox" name="toppings[parmesan]" id="toppings_parmesan">
            <label for="toppings_parmesan">Parmesan</label>
            <br />
            <input type="checkbox" name="toppings[bluecheese]" id="toppings_bluecheese">
            <label for="toppings_bluecheese">Blue Cheese</label>
            <br />
            <input type="checkbox" name="toppings[cheddarmix]" id="toppings_cheddarmix">
            <label for="toppings_cheddarmix">Cheddar&lpar;Mixed with Mozzarella&rpar;</label>
         </fieldset>
         <h3>Dessert toppings</h3>
         <fieldset>
             <legend>Syrups</legend>
            <input type="checkbox" name="toppings[chocosyrup]" id="toppings_chocosyrup">
            <label for="toppings_chocosyrup">Chocolate Syrup</label>
            <br />
            <input type="checkbox" name="toppings[strawsyrup]" id="toppings_strawsyrup">
            <label for="toppings_strawsyrup">Strawberry Syrup</label>
            <br />
            <input type="checkbox" name="toppings[vansyrup]" id="toppings_vansyrup">
            <label for="toppings_vansyrup">Vanilla Syrup</label>
         </fieldset>
         <fieldset>
             <legend>Crumbs/Fruits</legend>
            <input type="checkbox" name="toppings[chococookie]" id="toppings_chococookie">
            <label for="toppings_chococookie">Chocolate Cookie</label>
            <br />
            <input type="checkbox" name="toppings[caramelcookie]" id="toppings_caramelcookie">
            <label for="toppings_caramelcookie">Caramel Cookie</label>
            <br />
            <input type="checkbox" name="toppings[peanutcookie]" id="toppings_peanutcookie">
            <label for="toppings_peanutcookie">Peanut Cookie</label>
            <br />
            <input type="checkbox" name="toppings[gingercookie]" id="toppings_gingercookie">
            <label for="toppings_gingercookie">Ginger Cookie</label>
            <br />
            <input type="checkbox" name="toppings[banana]" id="toppings_banana">
            <label for="toppings_banana">Banana</label>
            <br />
            <input type="checkbox" name="toppings[strawberry"] id="toppings_strawberry">
            <label for="toppings_strawberry">Strawberry</label>
            <br />
            <input type="checkbox" name="toppings[mango]" id="toppings_mango">
            <label for="toppings_mango">Mango</label>
            <br />
            <input type="checkbox" name="toppings[apple]" id="toppings_apple">
            <label for="toppings_apple">Apple</label>
        </fieldset>
        <fieldset>
            <input type="submit" name="submit" value="Submit" accesskey="S" /> <input type="reset" name="reset" value="Clear" />
        </fieldset>
      </form>
    </body>
    </html>
    
    Code (markup):

     
    Sri Shame, Jan 22, 2015 IP
  2. ScottOtten

    ScottOtten Greenhorn

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #2
    In form action use a processor.php file Where you can get values from Form posted

    For example

    $topping=htmlspecialchars(@$_GET['topping']); //Filters malicious code too
     
    ScottOtten, Feb 1, 2015 IP