Jump to content

Recommended Posts

yes, i got a submission form.

i paste it below

<?php
session_start();
ob_start();

if(!isset($_POST['submit'] ))
{
?>
<head>
<link rel="stylesheet" type="text/css" href="new.css" />
<title>Checklist System</title>
</head>
<body>
<div id="container">

<div id="banner">
<h1>Checklist System</h1> 
</div>

<div id="nav"color="backgrounds/blue01">
Welcome <?php echo $_SESSION['user'] ?><br><br><br>
<a href="view_users.php">View Users</a><br><br><a href="create_User.php">Create User Accounts</a><br><br><a href="edit_delete_user.php">Edit/Delete User</a><br><br><a href="end.php">Generate Checklist</a><br><br><a href="login_success.php">View all Checklists</a><br><br><br><a href="log_out.php">Sign Out</a>
</div>

<div id="content">
<h2>Enter Check Item and its Properties </h2>
<form method="POST" action="<?php $_SERVER['PHP_SELF']?>">
<table border="0" align="center" cellpadding="10" cellspacing="10">
<tr>
<td>Check Item: <input type="text" name="checkItem"></td></tr>
<tr><td><h3>Select Check Item's Corresponding Checklist Element</h3></td></tr>
<tr>
<td><input type="radio" name="element" value="radio">Radio Button<br></td>
</tr>
<tr>
<td><input type="radio" name="element" value="checkbox">Checkbox<br></td>
</tr>
<tr>
<td><input type="radio" name="element" value="text">Textbox<br></td>
</tr>
<tr><td>&nbsp</td></tr>
<tr><td><h3>Enter Labels for the chosen checklist element</h3></td></tr>
<td><FONT color="red" size="1">***enter labels seperated by commas***</FONT></td></tr>
<tr>
<td>Label : <input type="text" name="label" size="50"></td></tr>

<tr><td>&nbsp</td></tr>

<tr>
<td ><input type="hidden" id="num" name="num" value="<?php echo $_SESSION['count'];?>">
</td></tr>
<tr>
<td align="center"><input type="submit" name="submit" value="Submit">
</td></tr>
</table>
</form>
</div>


</div>
</body>
<?php
}
else
{
$num = $_POST['num'];
$check_item[] =$_POST['checkItem'];
        $check_item[] = $_POST['element'];
        $check_item[] = $_POST['label'];
        $_SESSION["$num"]  = $check_item;
$_SESSION['count'] = ++$num ;

       if($num == $_SESSION['num_Items'])
{
	//$_SESSION['checks'] = $check_item ;
	header("location:checking1.php");
} 
else
{	
	header("location:come.php");
}

}
ob_flush();
?>

Explain what your code is supposed to do, The following makes no sense:

else
{
$num = $_POST['num'];
$check_item[] =$_POST['checkItem'];
        $check_item[] = $_POST['element'];
        $check_item[] = $_POST['label'];
        $_SESSION["$num"]  = $check_item;
$_SESSION['count'] = ++$num ;

       if($num == $_SESSION['num_Items'])
{
	//$_SESSION['checks'] = $check_item ;
	header("location:checking1.php");
} 
else
{	
	header("location:come.php");
}

}

Hi,

i got a loop and i want session to save the value entered by the user on

every single loop.   is it possible for say the parameter for session to be a

variable? like $_SESSION[$row]??

 

pls show an example if possible.

 

Yes, it's possible. $_SESSION is just an array, so all array rules apply.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.