-- Sep 30 In-Class Exercise Thread
<?php
session_name("sessID");
session_start();
?>
<form>
<label for="item">Item:</label><br />
<input type="text" id="item" name="item" placeholder="Enter item here" /><br />
<input type="submit" id="submit" name="submit" value="Submit" />
</form>
<?php
if (!empty($_REQUEST[item])) $_SESSION["cart"][] = $_REQUEST[item];
foreach ($_SESSION["cart"] as $i) echo "$i<br />";
I'm assuming we don't need to do all the extra HTML stuff like <head> and what not, since it's just an exercise and it works fine without
<pre>
<?php
session_name("sessID");
session_start();
?>
<form>
<label for="item">Item:</label><br />
<input type="text" id="item" name="item" placeholder="Enter item here" /><br />
<input type="submit" id="submit" name="submit" value="Submit" />
</form>
<?php
if (!empty($_REQUEST[item])) $_SESSION["cart"][] = $_REQUEST[item];
foreach ($_SESSION["cart"] as $i) echo "$i<br />";
</pre>
I'm assuming we don't need to do all the extra HTML stuff like <head> and what not, since it's just an exercise and it works fine without