Jump to content

Unknown Problem


Ads

Recommended Posts

I see your problem. You are including this script on every page, but the $_REQUEST variables are only available on the first page after the person logs in. What you have to do is set a $_SESSION variable that holds the username (and password, although I would recommend against this as its a security risk), and then check those session variables on each page.

Link to comment
Share on other sites

I see your problem. You are including this script on every page, but the $_REQUEST variables are only available on the first page after the person logs in. What you have to do is set a $_SESSION variable that holds the username (and password, although I would recommend against this as its a security risk), and then check those session variables on each page.

 

Hmm Could you explain that a bit More, it is Quite late, and I am doing Homework hehe..math >.>

Link to comment
Share on other sites

They are stored in the Database.

I kind of ment where are they stored AFTER THE PERSON LOGS ON

 

There not :) Apart from when i call on them from the Database :D

Well for a Login to work, something has to be stored on the clients machine for a login to remain open, your going to have to better write your login script before you worry about and include for... whatever this is for. I was assuming this WAS for the login.
Link to comment
Share on other sites

No this was pretty much all for indexing the Database at the users Row.  My login script works Fine :)

 

~.~ Now I'm really confused at what your trying to do....

 

 

_REQUEST only works for a GET string (URL Request) a POST string (Header sent Request) or a COOKIE string (Client Machine Stored Request) if it's not somewhere in that, then your not going to be able to use this script at all.

Link to comment
Share on other sites

Hmm Could you explain that a bit More

 

$_REQUEST gets variables that have been passed to a page as $_POST variables (which are hidden) and $_GET (stored in the URL). These variables are (usually) created when a user enters information into a form and hits submit. They are carried to the next page, where a script can use them. However, unless the script forces these variables to keep on being passed from page to page, they are lost after one page. This means that the variables exist in the page after the user logs in, but when the user clicks any other page, they don't exist. Since they don't exist, when you use this code:

 

$email=$_REQUEST['email'];

 

$_REQUEST['email'] is empty, which means $email is empty, which means you get nothing back from your mysql query.

 

What you need to do is either set a cookie variable (not recommended) or a session variable (recommended) to hold the person's email address. This Then, you need to change the code I posted above to:

 

$email = $_SESSION['email'];

 

A $_SESSION variable is stored on the users machine (its a type of cookie) and can be accessed on any page, so after it has been set, you will have no worries.

 

Finally, I would suggest rethinking how you are doing all this. You shouldn't need to recover the users ID on EVERY page. Thats inefficient. So right after the user logs in, you should user their email address (skipping the whole step I mentioned above, as its unneccesary) to get their ID from your database, and save that ID as a session variable (which you are already doing). This will mean you can cut out pretty much that whole included step.

 

What you have right now is that you are trying to use the persons email to recover their id from the database, setting that id into a session variable on every page! This is horribly inefficient as it only needs to be done the one time. Once the session variable is there, its there until it expires and can be used on any page.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.