php - Controlling program flow with both forms and urls -


sorry noob question. have php script organized this:

switch(true) { case (isset($_post['login'])): // ...some code check login break; case (isset($_post['register'])): // ... script register new user etc. 

access each section of code controlled using name of submit buttons in forms. borrowed menu system uses url's command parameters instead of submit buttons. example url looks this:

http://myipaddress/gradebook/login.php?guid=51913a6e37e1b&command=newclass 

so, same control of program flow using url's tried adding @ beginning of file:

if (isset($_get['command'])) {   switch ($_get['command'])   {     case 'newclass':        $_post['basicsettings']='basicsettings';       $guid=$_get['guid'];       break;     case 'logout':       $_post['logout']='logout';       break;     case 'continue':       $guid=$_get['guid'];       $_post['continue']='continue';       break;  } } 

this doesn't work because $_get global array reset if next operation issues new url, , in cases user use submit button on form , not select menu item. can't use unset on $_get within php script because affects local copy. tried setting $_session command variable instead , refreshing page using header("location:login.php") reset $_get global array didn't work. here modified code:

session_start();  if (isset($_get['command']))  // if program flow control came url {   switch ($_get['command'])   // check script section use   {     case 'newclass':        $_post['basicsettings']='basicsettings';       $guid=$_get['guid'];       $_session['command']='basicsettings';       $_session['guid']=$guid;       header("location:login.php");       break;     case 'logout':       $_post['logout']='logout';       $_session['command']='logout';       header("location:login.php");       break;     case 'continueteacher':       $guid=$_get['guid'];       $_post['continueteacher']='continueteacher';       $_session['command']='continueteacher';       $_session['guid']=$guid;       header("location:login.php");       break;   } }  if (isset($_session['command'])) {   $var=$_session['command'];   $_post[$var]=$_session['command'];   $guid=$_session['guid'];   $_request['guid']=$_session['guid'];   unset($_session['command']); }  switch(true) { .. ...etc. 

i realize 1 way fix change menu system use submit buttons instead of url's, has downsides well. there way make work? assuming can see i'm trying , makes sense?


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -