Framesets and variable swapping

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
0tter22
Forum Newbie
Posts: 2
Joined: Fri Apr 29, 2005 12:27 pm

Framesets and variable swapping

Post by 0tter22 »

I have a frameset, with two frames, I simply need to pass the pass a password and username variable from the main frame, where it has been picked up from a form, to the second of the two frames which is a php memberpage. By the way it needs to be a fresh frameset.

The main frameset is member_frameset.php

Code: Select all

<?php 
session_start(); 

//create short variable names 
// Here I've collected the posted variables from a previous form 

$username = $HTTP_POST_VARS['username']; 
$passwd = $HTTP_POST_VARS['passwd']; 

?> 

<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
<title>Untitled Document</title> 
</head> 
<frameset rows="*" cols="222,*" framespacing="0" frameborder="NO" border="0"> 
<frame src="main_menu.htm" name="menuleft" scrolling="NO" noresize> 
<frame src="member.php" name="menumain"> 
</frameset> 
<noframes><body> 
</body></noframes> 
</html>
The frame where I need to pass the username and password to is member.php and it is:

Code: Select all

<?php 
//session_start(); 
// include function files for this application 
require_once('bookmark_fns.php'); 
//create short variable names 
//$username = $HTTP_POST_VARS['username']; 
//$passwd = $HTTP_POST_VARS['passwd']; 
if ($username && $passwd) 
// they have just tried logging in 
{ 
if (login($username, $passwd)) 
{ 
// if they are in the database register the user id 
$HTTP_SESSION_VARS['valid_user'] = $username; 
} 
else 
{ 
// unsuccessful login 
do_html_header('Problem:'); 
echo 'You could not be logged in. 
You must be logged in to view this page.'; 
do_html_url('login.php', 'Login'); 
do_html_footer(); 
exit; 
} 
} 

do_html_header('Home'); 

//echo "this is a test in member.php to see how far we've got"; 
//echo $username; 
//echo $passwd; 

check_valid_user(); 
// get the bookmarks this user has saved 
if ($url_array = get_user_urls($HTTP_SESSION_VARS['valid_user'])); 
display_user_urls($url_array); 

// give menu of options 
display_user_menu(); 

do_html_footer(); 
?>
The main frameset definitely gets the username and passwords correctly it's just does not get to the second frame. I've really tried every combination.

I'm a complete novice so please be as descriptive as you can possibly be on the solution.

I think the answer could be in calling the member.php bit and sending the variables attached to this (member.php?$username) well something like that, but again I'm not sure on the syntax and I'm not sure on how to send the two variables or even pick them up in the member.php.

Anyway any help would be gratefully received.

Bill
0tter22
Forum Newbie
Posts: 2
Joined: Fri Apr 29, 2005 12:27 pm

Post by 0tter22 »

You can either pass it through the frameset call (get method) like this:



PHP:
--------------------------------------------------------------------------------

<frame src="member.php?username=$username&password=$passwd" name="menumain">

--------------------------------------------------------------------------------



which will have some security issues, or you can create session variables for the username/password combination. Like this, and reference them in member.php.
// member_frameset.php

PHP:
--------------------------------------------------------------------------------

session_start();
$_SESSION[username] = $HTTP_POST_VARS['username'];
$_SESSION[passwd] = $HTTP_POST_VARS['passwd'];


This is now resolved, thanks ever so much to the wonderful Terfle.

Bill
method_man
Forum Contributor
Posts: 257
Joined: Sat Mar 19, 2005 1:38 am

Post by method_man »

read the forum rules
use the php tags when posting php

matt
Post Reply