Page 1 of 1

session variables

Posted: Thu Aug 26, 2004 5:20 am
by monel
ImageBech100 | Please use

Code: Select all

tags when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

I have login frame on my page and I need to fill two fields to log registered users.If it is successfull a want to start a session and register these two variables.I need a sign out button to appear instead of the fields,  otheswise show the login form again.It works but the registered variables do not pass to the other frames:((
Here is the code:

Code: Select all

<?
require("functions.php");
session_start();
$_session['vn']="$vn"; 
$_session['egn']="$egn"; 
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>toolbar4e</TITLE>
<meta http-equiv='Content-Type' content='text/html; charset=windows-1251'>
<link href='style.css' rel='stylesheet' type='text/css'></HEAD>
<BODY class='toolbar' topmargin='0' >
<FORM METHOD=POST ACTION='toolbar.php' target='toolbar'>
<table cellspacing='0' cellpadding='0' >
<tr>
	<td>
	<TABLE class='Toolbarhead' cellspacing='0' cellpadding='0'>
	<TR height='17px'>
<?php

if ((check_login($vn,$egn))==0)
	{
	echo"
	<TD >login</TD>
	</TR>
	</TABLE>
	<TABLE  width='140px'class='toolbar' cellspacing='0' cellpadding='0'>
	<TR >
		<TD class='normal'>
			<input type=text align=center valign=center color=#D7D5D5 value='VN' maxlength=4 name='vn' onfocus='if(this.value=='VN')this.value='';'  onblur='if(this.value=='')this.value='VN';'></input><br>
			<input type=text align='center' color=#D7D5D5 value='EGN' name='egn' maxlength=10 onfocus='if(this.value=='EGN')this.value='';' onblur='if(this.value=='')this.value='EGN';'></input>
			<input style='width:46%;text-align:center' type=submit name='loginbtn' align='center' color=#D7D5D5 value='[ Sign in]'></input>
	"; 
	}
	else 
	{
	echo"
	<TD >Log out</TD>
	</TR>
	</TABLE>
	<TABLE  width='140px'class='toolbar' cellspacing='0' cellpadding='0'>
	<TR >
		<TD class='normal'>
		<input style='width:46%;text-align:center' type=submit align='center' color=#D7D5D5 name='loginbtn' value='[Log out]'></input>
	";

	};
	?>
		</TD>
	</TR>
	</TABLE>
	</TD>
	
</tr>
<tr >
	<td>
	<BR>
<TABLE  width='136px' class='toolbar' cellspacing='0' cellpadding='0'>

	<TR >
	<TD>
		<?php 
		if ((check_login($vn,$egn))==1)
		{
		echo"
		<A class='toolbar' HREF='http://www.myweb.com/history.html' target='main'>&nbsp;Personal data</A><BR>";
		};
		?>
		<A class='toolbar' HREF='http://www.myweb.com/history.html' target='main'>&nbsp;History</A><BR>
		<A class='toolbar' HREF='http://www.myweb.com/schedule.html' target='main'>&nbsp;Schedule</A><BR>
    </TD>
</TR>

</TABLE>
</td>
</tr>
<tr>
<td >
</FORM>
</table>
</BODY>
</HTML>
?>
check_login function only checks if such user exist in the database and no session is being tarted in it:((
Can u help me??

ImageBech100 | Please use

Code: Select all

tags when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Thu Aug 26, 2004 7:01 am
by delorian
Please use $_SESSION[] not $_session[], that is a big difference.

Posted: Thu Aug 26, 2004 7:56 am
by monel
I changed it to $_SESSION[] but now I cannot login even with existing user :(
I also tried session_register("vn");...... again it is not passed to the main frame:(
I also tried to initialize the session in check_login function -- no result

What am I doing wrong??

Posted: Thu Aug 26, 2004 9:45 am
by feyd
it appears like your code is reliant on register_globals being on, is this "feature" turn on?

Posted: Mon Aug 30, 2004 2:03 am
by monel
Yes every visitor can check his own confidential data, that's because I need sessions.
it is turned on:(I checked many times:(

Posted: Tue Aug 31, 2004 6:42 am
by monel
Any ideas how I can post these seeion variables to the main fraim from the toolbar????Pleaaaase

Posted: Tue Aug 31, 2004 8:46 am
by ol4pr0

Code: Select all

session_start();
print_r($_SESSION); // output ?

Posted: Wed Sep 01, 2004 2:42 am
by monel
here is the output

Array ( [vn] => [egn] => )