RE: [PHP] SESSION variable to pass login ID
-Original Message- From: Nova [mailto:[EMAIL PROTECTED]] Sent: 12 January 2003 20:04 This statement doesnt look right to me. if(isset($_POST['userid']) isset($_POST['pword'])){ $_SESSION['user'] = $_POST['userid']; $_SESSION['password'] = $_POST['pword']; } Nowt wong wi' that! the if should be: if ((statement)(statement)) That's not true! The syntax of if is: if (expression) statement; and one possible expression is: expression expression so this is a valid if condition: if (expression expression) Now, you *may* need additional parentheses around the expressions if they contain lower-priority operators than , but they are not required. Also: a statement is *not* an expression, so the if condition can never include statements! Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] SESSION variable to pass login ID
Hi, I have been trying to solve the problem of using session variables, but I have not had any luck. What I want to do is simple, I want to set my userid and password in a login screen and use it later (in another php form) to log into the database. In my login PHP file I have the following: if(isset($_POST['userid']) isset($_POST['pword'])){ $_SESSION['user'] = $_POST['userid']; $_SESSION['password'] = $_POST['pword']; } In my connect to database PHP file I have: if(isset($_SESSION['user'])){ $user=$_SESSION['user']; echo Print $user; }else{ echo Print Missing User; } The message I always get is Print Missing User, so I must assume the global variable is not working. Can anyone help me out here? Thanks, Larry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION variable to pass login ID
Hi, Monday, January 13, 2003, 1:04:49 AM, you wrote: WG Hi, WG I have been trying to solve the problem of using session variables, but I WG have not had any luck. What I want to do is simple, I want to set my userid WG and password in a login screen and use it later (in another php form) to log WG into the database. WG In my login PHP file I have the following: WG if(isset($_POST['userid']) isset($_POST['pword'])){ WG $_SESSION['user'] = $_POST['userid']; WG $_SESSION['password'] = $_POST['pword']; WG } WG In my connect to database PHP file I have: WG if(isset($_SESSION['user'])){ WG $user=$_SESSION['user']; WG echo Print $user; WG }else{ WG echo Print Missing User; WG } WG The message I always get is Print Missing User, so I must assume the WG global variable is not working. Can anyone help me out here? WG Thanks, WG Larry Make sure you have session_start() at the begining of the second file. -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] SESSION variable to pass login ID
Tom, I do have a session_start() in both files, but it does not seem to help. - Larry -Original Message- From: Tom Rogers [mailto:[EMAIL PROTECTED]] Sent: Sunday, January 12, 2003 11:36 AM To: Willie G Cc: [EMAIL PROTECTED] Subject: Re: [PHP] SESSION variable to pass login ID Hi, Monday, January 13, 2003, 1:04:49 AM, you wrote: WG Hi, WG I have been trying to solve the problem of using session variables, but I WG have not had any luck. What I want to do is simple, I want to set my userid WG and password in a login screen and use it later (in another php form) to log WG into the database. WG In my login PHP file I have the following: WG if(isset($_POST['userid']) isset($_POST['pword'])){ WG $_SESSION['user'] = $_POST['userid']; WG $_SESSION['password'] = $_POST['pword']; WG } WG In my connect to database PHP file I have: WG if(isset($_SESSION['user'])){ WG $user=$_SESSION['user']; WG echo Print $user; WG }else{ WG echo Print Missing User; WG } WG The message I always get is Print Missing User, so I must assume the WG global variable is not working. Can anyone help me out here? WG Thanks, WG Larry Make sure you have session_start() at the begining of the second file. -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSION variable to pass login ID
This statement doesnt look right to me. if(isset($_POST['userid']) isset($_POST['pword'])){ $_SESSION['user'] = $_POST['userid']; $_SESSION['password'] = $_POST['pword']; } the if should be: if ((statement)(statement)) { } so: if ((isset($_POST['userid'])) (isset($_POST['pword']))) { $_SESSION['user'] = $_POST['userid']; $_SESSION['password'] = $_POST['pword']; } That should work. Willie G [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Tom, I do have a session_start() in both files, but it does not seem to help. - Larry -Original Message- From: Tom Rogers [mailto:[EMAIL PROTECTED]] Sent: Sunday, January 12, 2003 11:36 AM To: Willie G Cc: [EMAIL PROTECTED] Subject: Re: [PHP] SESSION variable to pass login ID Hi, Monday, January 13, 2003, 1:04:49 AM, you wrote: WG Hi, WG I have been trying to solve the problem of using session variables, but I WG have not had any luck. What I want to do is simple, I want to set my userid WG and password in a login screen and use it later (in another php form) to log WG into the database. WG In my login PHP file I have the following: WG if(isset($_POST['userid']) isset($_POST['pword'])){ WG $_SESSION['user'] = $_POST['userid']; WG $_SESSION['password'] = $_POST['pword']; WG } WG In my connect to database PHP file I have: WG if(isset($_SESSION['user'])){ WG $user=$_SESSION['user']; WG echo Print $user; WG }else{ WG echo Print Missing User; WG } WG The message I always get is Print Missing User, so I must assume the WG global variable is not working. Can anyone help me out here? WG Thanks, WG Larry Make sure you have session_start() at the begining of the second file. -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] SESSION variable to pass login ID
Hi, I just found my mistake. I added some debug logic, and found that the $_POST logic was in the calling form, not the called form. As soon as I moved the if(isset($_POST['userid']) isset($_POST['pword'])){ to the second form, everything started to work. Thanks to everyone who responded. - Larry -Original Message- From: Nova [mailto:[EMAIL PROTECTED]] Sent: Sunday, January 12, 2003 3:04 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] SESSION variable to pass login ID This statement doesnt look right to me. if(isset($_POST['userid']) isset($_POST['pword'])){ $_SESSION['user'] = $_POST['userid']; $_SESSION['password'] = $_POST['pword']; } the if should be: if ((statement)(statement)) { } so: if ((isset($_POST['userid'])) (isset($_POST['pword']))) { $_SESSION['user'] = $_POST['userid']; $_SESSION['password'] = $_POST['pword']; } That should work. Willie G [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Tom, I do have a session_start() in both files, but it does not seem to help. - Larry -Original Message- From: Tom Rogers [mailto:[EMAIL PROTECTED]] Sent: Sunday, January 12, 2003 11:36 AM To: Willie G Cc: [EMAIL PROTECTED] Subject: Re: [PHP] SESSION variable to pass login ID Hi, Monday, January 13, 2003, 1:04:49 AM, you wrote: WG Hi, WG I have been trying to solve the problem of using session variables, but I WG have not had any luck. What I want to do is simple, I want to set my userid WG and password in a login screen and use it later (in another php form) to log WG into the database. WG In my login PHP file I have the following: WG if(isset($_POST['userid']) isset($_POST['pword'])){ WG $_SESSION['user'] = $_POST['userid']; WG $_SESSION['password'] = $_POST['pword']; WG } WG In my connect to database PHP file I have: WG if(isset($_SESSION['user'])){ WG $user=$_SESSION['user']; WG echo Print $user; WG }else{ WG echo Print Missing User; WG } WG The message I always get is Print Missing User, so I must assume the WG global variable is not working. Can anyone help me out here? WG Thanks, WG Larry Make sure you have session_start() at the begining of the second file. -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] SESSION variable to pass login ID
Well, start debugging your code then. Do a print_r() of $_POST and $_SESSION at different points in your files. Maybe you're losing your session on a certain page or it's getting reset. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -Original Message- From: Willie G [mailto:[EMAIL PROTECTED]] Sent: Sunday, January 12, 2003 2:53 PM To: Tom Rogers; Willie G Cc: [EMAIL PROTECTED] Subject: RE: [PHP] SESSION variable to pass login ID Tom, I do have a session_start() in both files, but it does not seem to help. - Larry -Original Message- From: Tom Rogers [mailto:[EMAIL PROTECTED]] Sent: Sunday, January 12, 2003 11:36 AM To: Willie G Cc: [EMAIL PROTECTED] Subject: Re: [PHP] SESSION variable to pass login ID Hi, Monday, January 13, 2003, 1:04:49 AM, you wrote: WG Hi, WG I have been trying to solve the problem of using session variables, but I WG have not had any luck. What I want to do is simple, I want to set my userid WG and password in a login screen and use it later (in another php form) to log WG into the database. WG In my login PHP file I have the following: WG if(isset($_POST['userid']) isset($_POST['pword'])){ WG $_SESSION['user'] = $_POST['userid']; WG $_SESSION['password'] = $_POST['pword']; WG } WG In my connect to database PHP file I have: WG if(isset($_SESSION['user'])){ WG $user=$_SESSION['user']; WG echo Print $user; WG }else{ WG echo Print Missing User; WG } WG The message I always get is Print Missing User, so I must assume the WG global variable is not working. Can anyone help me out here? WG Thanks, WG Larry Make sure you have session_start() at the begining of the second file. -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php