roonnyy Posted June 2, 2009 Share Posted June 2, 2009 Hi guys, I've got 2 files script (form-using method post and session) that collects data from user with checkboxes. On first page (start.php) are 10 checboxes with some options. Users can select some of them and press SUBMIT button. After that all values from chechboxes are send with session to another page (check.php) here can user see what he fill in form and do a check. My problem is at this page I have got GO BACKĀ button for reason when user want change some answer. But when this button is pressed all checkbox values are reset although I'm use session. I also use session for texfileds and here I haven't got any problem all values from previous page (start.php) are here whern GO BACK button is press. I'll appreciate any working example for studying purposes. Quote Link to comment Share on other sites More sharing options...
Alt_F4 Posted June 2, 2009 Share Posted June 2, 2009 please post your code Quote Link to comment Share on other sites More sharing options...
lisa_85 Posted June 2, 2009 Share Posted June 2, 2009 Hi roonnyy, I found an example online with text fields and have modified it slightly to use checkboxes. Have a look at this code <?php session_start(); ?> <html> <head> <title>Checkbox Values</title> </head> <body> <form action='index.php' method='get'> Box1 <input type='checkbox' <?php echo $_SESSION['box1'] == 1 ? 'checked' : '' ?> name='box1' value="1"><br /> Box2 <input type='checkbox' <?php echo $_SESSION['box2'] == 2 ? 'checked' : '' ?> name='box2' value="2"><br /> Box3 <input type='checkbox' <?php echo $_SESSION['box3'] == 3 ? 'checked' : '' ?> name='box3' value="3"><br /> Box4 <input type='checkbox' <?php echo $_SESSION['box4'] == 4 ? 'checked' : '' ?> name='box4' value="4"><br /> Box5 <input type='checkbox' <?php echo $_SESSION['box5'] == 5 ? 'checked' : '' ?> name='box5' value="5"><br /> Box6 <input type='checkbox' <?php echo $_SESSION['box6'] == 6 ? 'checked' : '' ?> name='box6' value="6"><br /> Box7 <input type='checkbox' <?php echo $_SESSION['box7'] == 7 ? 'checked' : '' ?> name='box7' value="7"><br /> Box8 <input type='checkbox' <?php echo $_SESSION['box8'] == 8 ? 'checked' : '' ?> name='box8' value="8"><br /> Box9 <input type='checkbox' <?php echo $_SESSION['box9'] == 9 ? 'checked' : '' ?> name='box9' value="9"><br /> Box10 <input type='checkbox' <?php echo $_SESSION['box10'] == 10 ? 'checked' : '' ?> name='box10' value="10"><br /> <input type='submit' name='submit' value='Submit'> </form> </body> </html> <?php $_SESSION['box1']=$_GET['box1']; $_SESSION['box2']=$_GET['box2']; $_SESSION['box3']=$_GET['box3']; $_SESSION['box4']=$_GET['box4']; $_SESSION['box5']=$_GET['box5']; $_SESSION['box6']=$_GET['box6']; $_SESSION['box7']=$_GET['box7']; $_SESSION['box8']=$_GET['box8']; $_SESSION['box9']=$_GET['box9']; $_SESSION['box10']=$_GET['box10']; ?> Hope this helps you Quote Link to comment Share on other sites More sharing options...
roonnyy Posted June 2, 2009 Author Share Posted June 2, 2009 thanks lisa_85 and Alt_F4 for help. My problem is solved! Quote Link to comment 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.