shotos Posted July 23, 2008 Share Posted July 23, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/116212-can-_session-handle-a-variable-parameter/ Share on other sites More sharing options...
JonnyThunder Posted July 23, 2008 Share Posted July 23, 2008 Do you have anything at all? Like the submission form? Quote Link to comment https://forums.phpfreaks.com/topic/116212-can-_session-handle-a-variable-parameter/#findComment-597582 Share on other sites More sharing options...
shotos Posted July 23, 2008 Author Share Posted July 23, 2008 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> </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> </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(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/116212-can-_session-handle-a-variable-parameter/#findComment-597590 Share on other sites More sharing options...
wildteen88 Posted July 23, 2008 Share Posted July 23, 2008 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"); } } Quote Link to comment https://forums.phpfreaks.com/topic/116212-can-_session-handle-a-variable-parameter/#findComment-597725 Share on other sites More sharing options...
discomatt Posted July 23, 2008 Share Posted July 23, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/116212-can-_session-handle-a-variable-parameter/#findComment-597730 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.