Advertisement
Guest User

Untitled

a guest
Apr 17th, 2014
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. <?php
  2. define('THIS_PAGE', basename($_SERVER['PHP_SELF']));//shows webroot
  3.  
  4. if(isset($_POST['submit3'])){ //proces form - catches the post info when submit clicked
  5.  
  6. $arr = $_POST['sundae'];
  7. $lastElement = array_pop($arr);
  8.  
  9. if ($arr == ""){$myReturn = "stuff"; echo $myReturn;}
  10. else
  11. {$myReturn = "<span style="color:red; font-weight: bold">You have selected: " . implode(', ',$arr)." and ".$lastElement;
  12. $myReturn .= "</span> <br />";
  13. $myReturn .= '<input type="button" value="Reload page" onclick="reloadPage()" >';
  14. echo $myReturn;}
  15. }else{// show the form if no posties
  16. echo
  17. '
  18. <form action="myTest.php" method ="post">
  19. Select a size:<br />
  20. <input type="checkbox" name="sundae[]" value="One Scoop"> One Scoop<br />
  21. <input type="checkbox" name="sundae[]" value="Two Scoops"> Two Scoops<br />
  22. <input type="checkbox" name="sundae[]" value="Three Scoops"> Three Scoops<br />
  23.  
  24. <hr ><br />
  25.  
  26. Select a flavor:<br />
  27. <input type="checkbox" name="sundae[]" value="Chocolate">Chocolate<br />
  28. <input type="checkbox" name="sundae[]" value="Coffee">Coffee<br />
  29. <input type="checkbox" name="sundae[]" value="Double Fudge">Double Fudge<br />
  30.  
  31. <hr ><br />
  32.  
  33. Select your Toppings:<br />
  34. <input type="checkbox" name="sundae[]" value="Applesauce">Applesauce<br />
  35. <input type="checkbox" name="sundae[]" value="Blueberries">Blueberries<br />
  36.  
  37.  
  38. <input type="checkbox" name="sundae[]" value="Bubblegum">Bubblegum<br />
  39.  
  40. <input type="checkbox" name="sundae[]" value="Caramel">Caramel<br />
  41. <input type="checkbox" name="sundae[]" value="Hot Fudge">Hot Fudge<br />
  42. <input type="checkbox" name="sundae[]" value="Gummy Bears">Gummy Bears<br />
  43.  
  44. Select a Whip:<br />
  45. <input type="checkbox" name="sundae[]" value="Double Whipped Cream">Double Whipped Cream<br />
  46. <input type="checkbox" name="sundae[]" value="Marishino Cherry">Vanilla Whipped Cream<br />
  47. <input type="checkbox" name="sundae[]" value="Whipped Cream">Whipped Cream<br />
  48.  
  49. <hr ><br />
  50.  
  51. Select a Cherry:<br />
  52. <input type="checkbox" name="sundae[]" value="Black Cherry">Black Cherry<br />
  53. <input type="checkbox" name="sundae[]" value="Frozen Lake Cherry">Frozen Lake Cherry<br />
  54. <input type="checkbox" name="sundae[]" value="Marishino Cherry">Marishino Cherry<br />
  55. <br />
  56. <hr ><br />
  57.  
  58. Wopuld you like to add one "waffer-thin" mint? (No charge)<br />
  59. <input type="checkbox" name="sundae[]" value="Wafer-Thin Mint">Yes<br />
  60. <br />
  61. <input type="submit" name="submit3" >
  62. </form>
  63. ';
  64. }
  65. ?>
  66.  
  67. else
  68. {
  69. //> 1 because we already popped the last element
  70. if (count($arr) > 1) $lastElement = " and " . $lastElement;
  71. $myReturn = "<span style="color:red; font-weight: bold">You have selected: " . implode(', ',$arr).$lastElement;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement