473,657 Members | 2,585 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.p hp 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.p hp?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 3458
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_global s 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_global s-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
3609
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: ----------------------------------------------------------------------- <script language="JavaScript"> function addProcess(addPName,addSProcess,addPIndex) { var addProcessWindow = window.open('second.asp','mywindow','width=400,height=200');
4
1957
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, but we can't seem to find a good and clean solution anywhere. The options we looked into are as follows. Comments following the options are why we did not want to go with them:
1
6888
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 another. Session variables seem like the easiest, but I'm afraid of crashing the server after deploying with a few hundred users as opposed to just a few developers/testers. Any ideas?
2
3005
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 inetpub\anotherproject\test.aspx
7
2783
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 variables, and can do so just fine with a URL, and $_GET. What I would like to learn, and be very adept at using is the Form functions and how you pass through that. The problem in my comprehending this, is how does the original page know how...
28
3118
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 program. is this a valid concern? i'm thinking i can check the submitting page setting up something around the following the following code... $base_name = basename($_SERVER);
1
1494
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 best....). Having a class with static parameters???? Having a class that all the pages inherit??? (These last 2 ideas are coming from the news group but I do not quite understand them).
7
1873
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
14875
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 done in 3 steps: Step 1. Normal http login page. Step 2. A page called login.php that takes the posted username, stores it as $_SESSION, and registers it session_register("username"); user is taken to the personalized page according to his username...
6
3298
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 url) but how can i assign them to form variables ?
0
8397
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8605
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6167
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4158
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4315
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1957
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1620
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.