session_start() ?><!DOCTYPE html> <html> <head>
<title></title></head> <body>
<form method="get">
<label for="item">Shopping Cart:</label> <input type="text" name="item" id="item"> <input type="submit" name="submit"> </form>
<?php $_SESSION = $_REQUEST['item'] if (!empty($_SESSION)) { foreach($_SESSION as $item) { echo $item } } ?></body> </html>
<h1>Shopping Cart</h1> <form method="post"> <label>Shopping Cart Item</label> <input type="text" name="item" placeholder="Cart Item" /> <input type="submit" value="Add" /> </form><?php
if (!empty($_POST['item'])) { $_SESSION = $_POST['item']; foreach($_SESSION as $item) { echo $item; } }?> </body> </html>
<title> </title></head> <body>
Shopping Cart Item: <input type="text" name="item"></form>
<input type="submit" value="Add">
$_SESSION[] = $_POST['item']; if (!empty($_SESSION)) { foreach($_SESSION as $item) { echo $item; } }?>
session_start(); ?><!DOCTYPE html><html>
<head></head> <body> <form action="blah.php" method="get"> Shopping Cart: <input type="text" name="item"> <input type="submit"> </form> <?php if (!empty($_GET['item'])){ $_SESSION[$_GET['item']] = $_GET['item']; foreach($_SESSION as $item){ echo "<h1>" . $item . "</h1>"; } } ?> </body></html>
<body> <form method="get"> <label> Shopping Cart Item </label> <input type="text" name="item" id="item" /> <input type="submit" value="Add" /> </form> <?php if (!isset($_SESSION['cart'])) { $_SESSION['cart'] = array(); } $_SESSION['cart'][] = $_REQUEST['item']; if(!empty($_SESSION['cart'])) { foreach($_SESSION['cart'] as $item) { echo $item; echo "</html>
"; } } ?> </body>
<?php session_start(); // session_destroy(); ?> <html>
<head> <meta charset="utf-8"> <title>HTML basics</title> </head>
<body> <form method="POST"> <label for="item">Shopping Cart Item:</label>
<input type="text" id="item" name="item">
<input type="submit" value="Add"> </form>
<?php
echo "CURRENT ITEMS:
"; if(!empty($_REQUEST)){ $_SESSION[$_REQUEST["item"]] = $_REQUEST["item"]; } if (!empty($_SESSION)){ foreach ($_SESSION as $item) { echo $item. "
"; } } ?> </body>
</html><pre>