scotchegg78 Posted August 25, 2007 Share Posted August 25, 2007 Hey guys Having a nightmare with an issue of redirecting my companydata_add.php I have the form page calling this php script, it inserts the data fine, and then i want it to redirect to the display data screen. The companydata_details.php to display data accepts $companyid = $_GET["id"]; ... $companyid = mysql_insert_id (); $file = "companydata_details.php?id=" . $companyid; include $file; but it just hangs on the script and fails to load the companydata_details.php page. It does of course work without the url parameters been added?? Also I cannot use header as this is a page within an index of pages split in css using includes why wont include work !! thanks in adv x Quote Link to comment https://forums.phpfreaks.com/topic/66667-solved-please-help-love-you-lots-and-lots-if-you-do-includes-with-id-gets/ Share on other sites More sharing options...
MadTechie Posted August 25, 2007 Share Posted August 25, 2007 if you have 2 scripts and you recieve the GET['ID'] from one, any script included will also get that value.. ie <?php echo $_GET['ID']."<br>"; include "script2.php" ?> <?php echo $_GET['ID']."<br>"; ?> 12 12 Now, if you want to pass $_GET['ID'] without recieving it.. you can do this <?php $_GET['ID'] = 12; include "script2.php" ?> but i would recommend you modify the script your including like this if(isset($_GET['ID']) || !empty($passeddata)) { //... } then just set $passeddata in the first script and call as normal EDIT: so a quick fix ... $companyid = mysql_insert_id (); $_GET['id'] = $companyid; $file = "companydata_details.php"; include $file; Quote Link to comment https://forums.phpfreaks.com/topic/66667-solved-please-help-love-you-lots-and-lots-if-you-do-includes-with-id-gets/#findComment-334004 Share on other sites More sharing options...
scotchegg78 Posted August 25, 2007 Author Share Posted August 25, 2007 Hi thanks I am reading over your post, but i am not sure its what i am after? I have 3 pages, page 1 - input form , form calls page 2 to process form and insert data to database. page 2 processing form, when its done it calls page 3 to display data. page 3 - display data, it gets the data from a get variable passed from page 2 from include with ?id= etc etc with me? thanks for you help btw. Quote Link to comment https://forums.phpfreaks.com/topic/66667-solved-please-help-love-you-lots-and-lots-if-you-do-includes-with-id-gets/#findComment-334007 Share on other sites More sharing options...
MadTechie Posted August 25, 2007 Share Posted August 25, 2007 in which case.. page1 - the form.. action to page 2.. redirects to page 3.. if your stuck on the move from page 2 to 3 then i would use headers header("Location: newpage.php?id=1"); Quote Link to comment https://forums.phpfreaks.com/topic/66667-solved-please-help-love-you-lots-and-lots-if-you-do-includes-with-id-gets/#findComment-334012 Share on other sites More sharing options...
scotchegg78 Posted August 25, 2007 Author Share Posted August 25, 2007 Mad Tech the quick fix got it, i cannot use headers as they are in an index of 3 pages - top / nav etc etc. Your a star mate, niceness! I never realised you could set the varible and ofcourse the include file would pick it up. I owe you a beer. Quote Link to comment https://forums.phpfreaks.com/topic/66667-solved-please-help-love-you-lots-and-lots-if-you-do-includes-with-id-gets/#findComment-334014 Share on other sites More sharing options...
scotchegg78 Posted August 25, 2007 Author Share Posted August 25, 2007 No its not working right ?! arrrr!! the inlcude is taking over the full page and not loading the page within my index Quote Link to comment https://forums.phpfreaks.com/topic/66667-solved-please-help-love-you-lots-and-lots-if-you-do-includes-with-id-gets/#findComment-334056 Share on other sites More sharing options...
scotchegg78 Posted August 25, 2007 Author Share Posted August 25, 2007 ok fixed it with passing the index mainpage to load via a get aswell.. eg.. $companyid = mysql_insert_id (); $_GET['id'] = $companyid; $_GET['p'] = "companydata_details.php"; $file = "index.php"; include $file; Quote Link to comment https://forums.phpfreaks.com/topic/66667-solved-please-help-love-you-lots-and-lots-if-you-do-includes-with-id-gets/#findComment-334060 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.