![]() |
My Login Script
It has been a while since I have done any coding and I am having a problem with my login script. It has worked in the past though so im unsure what to do. Here goes....
This is where the information gets put in (its already connected to the database) PHP Code:
And then this is where it gets linked too. PHP Code:
The following errors are shown Code:
( ! ) Notice: And it also says "Please fill out all the fields". Any help would be greately appreciated! |
Looks like you used to have register_globals on and PHP <5.3. The errors tell you all you need to know. The $user and $pass variables need to be changed to
$_POST['user'] and $_POST['pass']. The deprecated error is because session_is_registered has been deprecated and will be removed in upcoming PHP releases. You should be using:PHP Code:
|
Yeah if I remember rightly it was php 4. So making this change should fix it?
|
Hmmm well I have fixed the problems and gained another one ha ha.
This is the login script and it seems to be working fine now PHP Code:
PHP Code:
|
if this is the exact code, you're missing an opening bracket after the first else.
|
Ah yes well spotted. This does not make a difference though, the error lies with carrying on the session
|
I am still stuck with this if anyone is able to help
|
Quote:
|
Quote:
Quote:
Quote:
To counteract this: PHP Code:
|
Thank you I will try this when I get back. I didnt think starting the session at the top of the login page because at that point you are not actually logged in but I think I understand now.
|
I dont understand why im having such a problem with this. Its still saying the variables on the updates file arent being recognised. So the session isnt being started on the login file. I dont understand why im having such a problem with this. Here are what the files are now
This is login.php PHP Code:
And this is updates.php PHP Code:
The error im getting on updates.php is ( ! ) Notice: Undefined index: user in C:\wamp\www\updates.php on line 4 Call Stack # Time Memory Function Location 1 0.0009 674216 {main}( ) ..\updates.php:0 ( ! ) Notice: Undefined index: pass in C:\wamp\www\updates.php on line 5 Call Stack # Time Memory Function Location 1 0.0009 674216 {main}( ) ..\updates.php:0 How do I make the session register properly on login.php and continue over to updates. |
I've already told you how to deal with sessions using session_start().
You either go back and read my advice again or you give up. Where did I tell you to put session_start() ? - The top of your scripts. Why didn't you do it in login.php? - Why have you left it down in an else clause after starting your html output with your header? - Did you think that I was just speaking unimportant gibberish or something? As for the undefined index messages, these two lines I gave you earlier: $user = mysql_real_escape_string($_POST['user']); $pass = mysql_real_escape_string($_POST['pass']); Change $_POST['user'] and $_POST['pass'] so that they match the names of the login fields in your html. That means if you have: <input type="text" name"username"> you change $_POST['user'] to $_POST['username'] and the same for the password field. |
Apologies I did make these changes in login.php I just copied the old version of the text to here. And my html is matching up with user and pass etc...
That is why I dont understand the issues I am having. Just so I am not mistaken, sessions will work on a offline server wont they? If the html didnt match up the $stat variable wouldnt be working on login.php but it is. It just isnt carrying over to updates.php I am not using session_register() anywhere is this the reason? |
Quote:
By 'offline server' do you mean you have put your browser in offline mode OR do you mean you have a locally installed WAMP system? If you have a WAMP (Windows Apache, MySQL & PHP) system then yes sessions will work on your machine regardless of whether you are connected to the internet or not. If you have your browser in offline mode then no. As you're unwilling to show the actual correct version of login.php there is little else we can do to assist you. You've shown an unmodified version since my last attempt to help you and then said that you have another version and posted the old version. If you have the newer version why are you not showing it? Also in your login.php there appears to be no mysql login details (unless its in head.php but then what are you doing in updates.php?) As for the sessions, you appear to be thinking that you are trying to take the $user and $pass variables from the session. I've told you earlier that this previously worked because of register globals being turned on in PHP4 which is completely different to the use of sessions. register globals was turned off by default in php 5 so your variables will no longer work like that - thats why you must take them from the $_POST array and sanitize them using mysql_real_escape_string() at a minimum (or use any other protection you like). As for sessions, I've not see you use the $_SESSION array anywhere in your code so I am at a loss to explain why you claim sessions are not working :confused: :eek: |
Yeah sorry I am using wampserver.
Here is my login.php PHP Code:
Th mysql connecion is within head.php and updates.php will basically be my first page within the website (once logged in). Once again, apologies for all the trouble. I just cant get my head around what im doing wrong here. |
| All times are GMT +1. The time now is 03:39 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.