mannyee Posted March 21, 2010 Share Posted March 21, 2010 hi guys!! I am having a tough time in automatically passing a variable from one page to another through query string. For instance, in the following code when the case is modify (the following code is in the index.php and $catId is the value obtained when a user clicks modify link in the index.php), i would like to pass the $catId automatically to modify.php without the user knowing anything about what's going on... case 'modify' : $catId=$_GET['catId']; $content = 'modify.php'; $pageTitle = 'Shop Admin Control Panel - Modify Category'; break; i perceived a wild idea(i'm a php newbie) as follows: case 'modify' : $catId=$_GET['catId']; $content = 'modify.php?catId=$catId'; $pageTitle = 'Shop Admin Control Panel - Modify Category'; break; but that din't work.....so pls help guys..... Link to comment https://forums.phpfreaks.com/topic/195987-auto-redirection-problem/ Share on other sites More sharing options...
inversesoft123 Posted March 21, 2010 Share Posted March 21, 2010 case 'modify' : $catId=$_GET['catId']; $content = "http://domain.com/modify.php?catId=$catId"; header("Location: $content"); $pageTitle = 'Shop Admin Control Panel - Modify Category'; break; Link to comment https://forums.phpfreaks.com/topic/195987-auto-redirection-problem/#findComment-1029453 Share on other sites More sharing options...
mannyee Posted March 21, 2010 Author Share Posted March 21, 2010 thanks for your reply..... but alas.... i must say that because of me not being able to explain properly about the situation in words (since english is not my mother language), although the solution you gave me works, i am not getting what i want..... actually, "modify.php" is a page where user doesn't have to view(or do anything else).....its more of a template which contains a form and where certain actions take place and for those actions to take place.....$_GET['catId'] is required...... this page is then assigned to $content in the case and later when the switch case exits..... i use the function require_once '../include/template.php'; the template.php looks as follows td width="600" valign="top" class="contentArea"><table width="100%" border="0" cellspacing="0" cellpadding="20"> <tr> <td> <?php require_once $content; ?> </td> </tr> the template.php is a templating file which i use for all other pages add.php,delete.php etc. what i want is not redirect a user to the modify.php page (as i mentioned in the subject....pardon me).....only just to pass the $catId variable using get method if u guys still don't understand yet and don't mind to peek into can i paste few code snippets so that you can understand the abstract? Link to comment https://forums.phpfreaks.com/topic/195987-auto-redirection-problem/#findComment-1029458 Share on other sites More sharing options...
inversesoft123 Posted March 21, 2010 Share Posted March 21, 2010 Don't do anything. :-) The variable is already there, just use it. You may want to study up on "scope" however: http://php.net/manual/en/language.variables.scope.php If you are in a function, you need to pass $name to that function, or you need to declare it "global" Passing it in is almost always better. If you just want the original $_GET data, raw and unfiltered, $_GET is a "superglobal" and you can juse it anywhere, any time. Link to comment https://forums.phpfreaks.com/topic/195987-auto-redirection-problem/#findComment-1029464 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.