kenlyle
|
| Posted: 02/25/2002, 5:06 PM |
|
I want to set a session variable for the sex (technically, I guess gender would be more correct) of the user, as retrieved from their profile.
I did a Custom Login, retrieving the generated code, and now have this:
===================
$db->query("SELECT InputID, Sex FROM IntroInputOrig WHERE Email =" . tosql($sLogin, "Text") . " AND Password=" . tosql($sPassword, "Text"));
$is_passed = $db->next_record();
if($is_passed)
{
//-------------------------------
// Login and password passed
//-------------------------------
set_session("UserID", $db->f("InputID"));
set_session("sex", $db->f("Sex"));
===========================================
I just tried to clone what was done to set the UserID, but the session variable sex is not being set. I tried echoing it in a later page, and it is null. Don't understand....
Is there something obviously wrong with this approach? Is there a better way?
Thanks.
|
|
|
 |
Alex Alexapolsky
|
| Posted: 02/26/2002, 1:53 AM |
|
This is obviousy caused by empty value returned by $db->f("Sex"));
1) You may specify wrong field name , pay attention to case
2) Is UserID variable set ?
3) May be sex field for a given user is empty.
Try to print it out before assigning it to session var
|
|
|
 |
kenlyle
|
| Posted: 02/26/2002, 6:35 AM |
|
1) You may specify wrong field name , pay attention to case
No, I am looking at it in PHPMyAdmin, and the field is "Sex"
2) Is UserID variable set ?
Yes, UserID is set, because after login, I go to the Profile (Record) page, which
pulls back all the correct details into radio fields (*including the Sex field*)
3) May be sex field for a given user is empty.
Good thought, but not in this case.
The app is at http://nextwave.phpwebhosting.com/questmary/Login.php - you can
login withkenlyle@yahoo.com and 65 - you will see that all the radio buttons
populate from the database. I have checked, and the values are correct.
Any other thoughts?
|
|
|
 |
kenlyle
|
| Posted: 02/26/2002, 7:14 AM |
|
I've replicated the database to my local Apache/MySQL on Windows machine,
confirmed the case of the Sex field, both in MySQL and in Codecharge. Still, the
Session var is not being set.
I also tried to do a dlookup to get the Sex based on the Inputid = get_session
("UserID"), which didn't work, either.
I'm stumped...any help would be much appreciated...
|
|
|
 |
kenlyle
|
| Posted: 02/26/2002, 7:48 AM |
|
Sarah's issue, mid=6998 seems to be related...either get_session or dlookup seems
to be broken...
|
|
|
 |
kenlyle
|
| Posted: 02/26/2002, 8:05 AM |
|
In my external file, questionaire.php
$uid = get_session("UserID");
doesn't work- echo of $uid produces nothing. Therefore...
$sexparm = dlookup("IntroInputOrig","Sex","Inputid=".tosql(get_session("UserID"),"Text")); This line based on Nicole's Mid=5898
doesn't work either...
Help!?
|
|
|
 |
kenlyle
|
| Posted: 02/26/2002, 9:41 AM |
|
Well, I'd asked my 'programmer' here whether I needed to do anything special to
make my PHP files part of PHP session tracking, and he said 'No'...
Turns out you need a session_start(); in every file. Case closed.
|
|
|
 |
|