Hi,
I'm really having a tough time trying to implement a solution which add's a delete button next to a customers selection, that when clicked removes that individual item from the session. My code is lited below. - If you could guide me with code alterations - or perhaps another way of doing it that would be great!.
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgstyle="color:#FFFFFF">
<form method="post" action="basket.php" name="test">
<p>
<input type="checkbox" name="1" value="Company 1">
<input type="checkbox" name="2" value="Company 2">
<input type="checkbox" name="3" value="Company 3">
<input type="checkbox" name="4" value="Company 4">
<input type="checkbox" name="5" value="Company 5">
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
</body>
</html>
This is the index page
Which would goto.... the page listed below - now this is the page I REALLY need help implemeting a delete button to each selection (much like a shopping cart) - which would then remove that specif selection and then refresh the page.
<?php
// start the session
session_start();
header("Cache-control: private"); //IE 6 Fix
echo "<strong>Franchise Selection</strong><br />";
// Get the user's input from the form
$Co1 = $_POST['1'];
// Establish if anything returned
IF ($Co1 == TRUE) {
// Register session key with the value
$_SESSION[] = $Co1;
}
$Co2 = $_POST['2'];
IF ($Co2 == TRUE) {
$_SESSION[] = $Co2;
}
$Co3 = $_POST['3'];
IF ($Co3 == TRUE) {
$_SESSION[] = $Co3;
}
$Co4 = $_POST['4'];
IF ($Co4 == TRUE) {
$_SESSION[] = $Co4;
}
$Co5 = $_POST['5'];
IF ($Co5 == TRUE) {
$_SESSION[] = $Co5;
}
// Display the sssion information:
$num_elements = count ($_SESSION);
// count how many entries in the array
//
echo "<form method='post' action='basket2.php' name='test1'>";
for ($idx = 0; $idx < $num_elements; ++$idx){
echo ("$_SESSION[$idx]");
echo "<input type='checkbox' name='$_SESSION[$idx]' value='$_SESSION[$idx]'><br>";
}
echo "<input type='submit' name='Submit' value='Submit'>";
echo "</form>";
//echo $_SESSION['1'];
echo $num_elements;
?>
Welcome to my website <strong><? echo $_SESSION['name']; ?></strong>!<br />
Let's see what happens on the <a href="page3.php">next page.</a><br /><br /> ?>
I really, need some help on this. Hope someone can assist me.
Regards
Ben