Challenge for php guru - this is making my head ache!
Posted: Tue Mar 22, 2005 1:09 pm
I'm having a trouble with an i-frame and variable passing. I am not sure if what I am attempting is possible but knowing how versatile php is I hopeful.
I am writing an admin system which requires a login. Now the screen if you can picture it, consists of two parts:
- a left hand navigation
- a main right hand side
The main right hand side is an i-frame. I want to use this so that the entire page doesn't have to re-load each time an option is chossen from the left-hand menu.
Now I am using the following sample code in the frame to ask for a username:
The above code works ok and passes the variable 'username' successfully once the form is submitted.
Now the problem is that I have, as I mentioned earlier, a left hand side navigation menu. Now these link to the i-frame as follows:
<a href=main.php?function=profile target=main>...<a>
the variable function is called in the 'main.php' script and as the name suggests, it's the title of a function. In this case the function is called 'profile'.
Again this works perfectly. When I click the link the variable 'function' is passed and my function called 'profile' executes as I want.
Now my problem is that I also want to call my function 'profile' with a paramter - that being the username. The left-hand navigation menu has no reference to the 'username' variable since this is only determined once the form has been submitted within the i-frame. The lefthand side navigation only executs once when the entire script is first called.
I am guessing that I only need to send the 'function' variable (which is static and will not change) but then how do I then somehow reference the 'username' variable, as a global or cookie perhaps?
If anyone could suggest anything or point me in the right direction I would be very much grateful.
Many thanks for reading this much!
Rob.
feyd | Please review how to post code using
I am writing an admin system which requires a login. Now the screen if you can picture it, consists of two parts:
- a left hand navigation
- a main right hand side
The main right hand side is an i-frame. I want to use this so that the entire page doesn't have to re-load each time an option is chossen from the left-hand menu.
Now I am using the following sample code in the frame to ask for a username:
Code: Select all
<?php
$username=$_GET['username'];
if (isset($_GET['submit'])){
// if form is submitted to this.....
}
else{
?>
form action="<? $PHP_SELF; ?>">
<p class="bodytext">Please input your username.</p>
<p class=bodytext>
<input type="text" size="15" name=username
</p>
<input class=button type="submit" value="Submit" name="submit">
</form>
<?
}
?>Now the problem is that I have, as I mentioned earlier, a left hand side navigation menu. Now these link to the i-frame as follows:
<a href=main.php?function=profile target=main>...<a>
the variable function is called in the 'main.php' script and as the name suggests, it's the title of a function. In this case the function is called 'profile'.
Again this works perfectly. When I click the link the variable 'function' is passed and my function called 'profile' executes as I want.
Now my problem is that I also want to call my function 'profile' with a paramter - that being the username. The left-hand navigation menu has no reference to the 'username' variable since this is only determined once the form has been submitted within the i-frame. The lefthand side navigation only executs once when the entire script is first called.
I am guessing that I only need to send the 'function' variable (which is static and will not change) but then how do I then somehow reference the 'username' variable, as a global or cookie perhaps?
If anyone could suggest anything or point me in the right direction I would be very much grateful.
Many thanks for reading this much!
Rob.
feyd | Please review how to post code using
Code: Select all
andCode: Select all
tags. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]