473,503 Members | 1,877 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing variables between pages in URL

3 New Member
Yes In know this has been covered in other ways, but after searching the forum I did not find a specific solution that fit my application. Maybe I overlooked something, so I'm sory if I did.

Here's what I have got. It's very simple (or at least should be). I have a page on my site that has a URL of:

http://mysite.come/page.php?gid=1

And in that page I have an iframe that calls for the gid variable like this:
Expand|Select|Wrap|Line Numbers
  1. <iframe src="family.iframe.php?gid=<?php echo $gid; ?>"
  2.  
family.iframe.php is another page I have that has formatting and other stuff on it. I basically gets called over and over again until there is nothing left to display. This is not the problem though. I have this setup working in a different fashion elsewhere. Plus I can go directly to mysite.com/family.iframe.php?gid=1 and get the results I want on a full page. But I want it to go in that iframe I have created. Am I missing a bit of code that pulls the 'gid=1' from the url and inserts it into the 'echo' section? I have tried using the $var=$_GET method with no luck as well. Any ideas?
Aug 11 '07 #1
8 3433
pbmods
5,821 Recognized Expert Expert
Heya, docebrown. Welcome to TSDN!

Please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.

The correct syntax is:
Expand|Select|Wrap|Line Numbers
  1. <iframe src="family.iframe.php?gid=<?php echo $_GET['gid']; ?>"
  2.  
Aug 11 '07 #2
docebrown
3 New Member
Sorry about that. Thanks for the correction. Does anyone have any idea as to why I can not grab the 'gid' variable?
Aug 13 '07 #3
pbmods
5,821 Recognized Expert Expert
Heya, docebrown.

This usually has to do with whether the register_globals directive is turned on in your php.ini file.

As a general rule, it is considered a good idea to not only know beforehand what the variables should be named, but also where they are coming from. For example, these three variables are distinct:
Expand|Select|Wrap|Line Numbers
  1. $var1 = $_GET['gid'];  // Passed in URL
  2. $var2 = $_POST['gid']; // Generally passed as part of submitted form data
  3. $var3 = $_COOKIE['gid']; // Stored in a cookie
  4.  
If you are expecting your variable to be passed in the URL (i.e., $_GET), then you're probably not too concerned about security.

On the other hand, if you are doing sensitive stuff, such as changing User account information, you'll want to make sure that these values are passed via post so as to discourage XSS. In this case, it becomes important to be able to explicitly use $_POST['var'].

If you want register_globals-like behavior in your scripts, consider adding this line at the top:
Expand|Select|Wrap|Line Numbers
  1. $gid = $_GET['gid'];
  2.  
Aug 13 '07 #4
docebrown
3 New Member
Thanks for the help on this. I checked and that setting IS turned OFF and my admin won't change it. So I used your remedy and instead of just using the:

Expand|Select|Wrap|Line Numbers
  1. <?PHP echo $gid; ?>
I used

Expand|Select|Wrap|Line Numbers
  1. <?PHP echo $_GET['gid']; ?>
and it works like a charm. Thanks for the explanation on the different ways to pass and pull vairables. I am not all that familiar with PHP and HTML, but I know enough to get myself into trouble. That explanation will help me in another area I am working on! Thanks again!
Aug 17 '07 #5
pbmods
5,821 Recognized Expert Expert
Heya, docebrown.

Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)
Aug 18 '07 #6
kierandes
25 New Member
Hi guys,
I'm a bit of a PHP noob so patience is required :). I'm probably doing something basic incorrectly but I would like to use the variable called src1 in a url I either echo or use printf. its currently showing the iframe but no url for it.

You see I am taking variables from MySql and using them to change the url based on user input. I want to be able to take the php variable thats got the values from the database and then place this new url in the iframe.
Any Input would be greatly appreciated. Thanks

Expand|Select|Wrap|Line Numbers
  1. $src1 = 'somewhere;
  2. $myVar = $_GET['src1'];
  3.  
  4. printf  ('<html>
  5.  
  6.     <iframe id="I1" name="I1" style="width: 892px; height: 450px" src=="http://www.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=<?PHP echo $_GET['src1']; ?> ">
Jun 5 '09 #7
Markus
6,050 Recognized Expert Expert
@kierandes
That ain't too hard, friend. You've pretty much got it done, just not quite ;)

Doing <?php ... ?> inside a string will do sod all. Instead, you need to close the string, then call your variable, and then reopen your string.

Check out the following:

Expand|Select|Wrap|Line Numbers
  1. $name = "mark";
  2.  
  3. echo "My name is ", $name, ". Nice to meet you.";
  4. // Or (notice the difference in concatenation)
  5. echo "My name is " . $name . ". Nice to meet you.
  6. // The first option is faster.
  7.  
Try and use this in your code.
Jun 5 '09 #8
kierandes
25 New Member
@Markus
Thanks Mate,
THis is my attempt at what your suggesting. Its not quite right yet (my attempt).

Expand|Select|Wrap|Line Numbers
  1. echo "<iframe SRC=\"" . "http://www.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=" . $lat_mins . "width="100%" height=\"100%\" frameborder=\"0\">If you can read this your browser does not support iframes.</iframe>";
Jun 5 '09 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3595
by: Consuelo Guenther | last post by:
Hello, I am having problems with passing variables between pages. I have the following: First asp page has the function: -----------------------------------------------------------------------...
4
1953
by: Doruk | last post by:
The problem that we are experiencing is simple: We want to pass certain parameters from a page with several server controls to another page. We want to do this in a dotnet compliant manner,...
1
6869
by: Eric | last post by:
Hello, I am trying to come up with the best way to pass large amounts of data from page to page, namely a data table. The user needs to enter data into a form in one page and confirm it on...
2
3001
by: Roy | last post by:
Hey all, Is it possible to pass session variables between pages in separate projects? For example: inetpub\thisproject\blah.aspx has a session variable and response.redirects the user to...
7
2769
by: Khai | last post by:
First off, yes, I understand the crapload of tutorials out there, (well, rather, I understand there /are/ a crapload of tutorials out there), the problem is my comprehension. I'm trying to pass...
28
3096
by: Skeets | last post by:
i'm passing session and hidden variables between pages. not to mention post values. i'm a little concerned that someone with sufficient knowledge could spoof these vlaues and manipulate the...
1
1483
by: Carly | last post by:
Hi, I work in Visual Basic .NET 2002 using ASP.NET. I am wondering what would be the best way to store/pass variables between pages. (Sessions are sooo simple to use but I hear they are not the...
7
1869
by: Smokey Grindle | last post by:
For a website that has users logged into it using sessions, its it best to pass data between pages in session variables or through query strings?
22
14854
by: K. A. | last post by:
I have two servers at work, 'A' for testing and development, and server 'B' for production. On server A, I wrote a PHP test code to login users then direct them to a personalized page. This is...
6
3282
by: coool | last post by:
Hi :) anyone knows how can I send variables from a php page to a form - i need to fill the form with these variables ? maybe using (the process of passing variables to other pages - through...
0
7204
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7091
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7282
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6998
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7464
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5586
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3162
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1516
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
741
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.