Jump to content

[SOLVED] Please help. love you lots and lots if you do! includes with ?id= gets?


scotchegg78

Recommended Posts

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

 

Link to comment
Share on other sites

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;

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.