DeepakJ Posted August 1, 2007 Share Posted August 1, 2007 This is my code: <?php if ($_GET['verif']){ session_start(); $_SESSION['pageselect'] = "verif.php"; echo '<script>window.location = "index.html"</script>'; } elseif ($_GET['sinput']){ session_start(); $_SESSION['pageselect'] = "sinput.php"; echo '<script>window.location = "index.html"</script>'; } elseif ($_GET['linput']){ session_start(); $_SESSION['pageselect'] = "linput1.php"; echo '<script>window.location = "index.html"</script>'; } elseif ($_GET['vdata']){ session_start(); $_SESSION['pageselect'] = "viewdata.php"; echo '<script>window.location = "index.html"</script>'; } elseif ($_GET['rdata']){ session_start(); $_SESSION['pageselect'] = "reportdata.php"; echo '<script>window.location = "index.html"</script>'; } ?> <html><head><title>AlibreCam Verification System</title></head> <frameset rows="6%,50%"> <frame src="frame_a.html"> <frame src="<?php if(isset($_SESSION['pageselect'])){ echo $_SESSION['pageselect']; session_destroy();} else{ echo "verif.html"; } ?>"> </frameset> </html> <html><head><title>AlibreCam Verification System</title></head> <center><form action=process.php method=get> <input type="submit" value="Verification" name = "verif"> <input type="submit" value="Sales Input" name = "sinput"> <input type="submit" value="License Input" name = "linput"> <input type="submit" value="View Data" name = "vdata"> <input type="submit" value="Report Data" name = "rdata"> </form></center> </html> Quote Link to comment https://forums.phpfreaks.com/topic/62933-why-dont-these-sessions-work/ Share on other sites More sharing options...
DeepakJ Posted August 1, 2007 Author Share Posted August 1, 2007 Im basically trying to get the buttons to redirect based on the button clicked Quote Link to comment https://forums.phpfreaks.com/topic/62933-why-dont-these-sessions-work/#findComment-313356 Share on other sites More sharing options...
deadimp Posted August 2, 2007 Share Posted August 2, 2007 Well, I'm not sure which session part isn't working, but take a step back for now and look at how repetitve your code is. You could easily simplify that and make it more flexible. Plus, intead of using forms 'n buttons for the process, it would be easiers to make links, with a url being "process.php?page=..." Example: (it's kinda messy, but you get the point) //Arrays aren't better than using a class, but for a simple example you'll see what I'm saying $pages=array( array("stuff","Stuff to happen"), array("blarg","Stuff that won't happen"), array("etc","Et cetera"), ... ); //process.php - Checking which page to include $page=$pages[0]; //First page by default, if no others are found foreach ($pages as $p) { if ($_GET['page']==$p[0]) { $page=$p; break; } } $_SESSION['pageselect']=$page[0].".php"; //I'm not sure why you're doing this in the first place... header("Location: index.html"); //Outputting the options echo "Select a step:<ul>"; foreach ($pages as $p) { echo "<li><a href='process.php?page=$p[0]'>$p[1]</a></li>"; } echo "</ul>"; Quote Link to comment https://forums.phpfreaks.com/topic/62933-why-dont-these-sessions-work/#findComment-313573 Share on other sites More sharing options...
btherl Posted August 2, 2007 Share Posted August 2, 2007 You need to call session_start() at the beginning of your script in order for sessions to work (unless you have sessions set to start automatically) Quote Link to comment https://forums.phpfreaks.com/topic/62933-why-dont-these-sessions-work/#findComment-313604 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.