This is a discussion on "Login Script problems" within the PHP Forum section. This forum, and the thread "Login Script problems are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Login Script problems
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Login Script problems
hi all first time here.
I am making a login error checking script via php and mysql I have my html that is a form that sends information to my php script here is the script itself Quote:
then i went and made them all work together and that when i got problems the testing for blank entries work fine it sends me to the error page, checking for if a username exists in the database or is multi entries works fine. but when i go onto testing a proper username and password it sends me to error2.php page which is meant to only happen if there no entries or multi entries to which there is no multi entries of this user name and the username certainly exists. when i also tested with a bad password it also sent me to the error2.php instead of error3.php page. any help will be appericated as i can not work out what is wrong with the code or the logic of it. if things seems weird with the English i apologise i am dyslexic. |
|
|
|
|||
|
Re: Login Script problems
First of all, you've got a problem here:
|
|
|||
|
Re: Login Script problems
Currently your structure looks like this:
|
|
|||
|
Re: Login Script problems
In other words, you need to be more careful about enclosing your blocks of code within the correct if...elseif...else structure.
|
|
|||
|
Re: Login Script problems
Personally, I'd say you're also much better off with this:
Here's how I would have written the initial code you posted:
|
|
|||
|
Re: Login Script problems
Quote:
thank you for the advice on making the code better by connecting to the database once though i thought you had to conenct ever time you make a query |
|
|||
|
Re: Login Script problems
OK, so now you're down to standard debugging stuff. Here's how I do that...
1. Comment out any line that redirects. Just before that line, insert an echo line that says, "Redirecting to [someotherpage.php]" 2. Right after any open curly brace, insert a new line with an echo that says "if you're reading this, that must mean....." 3. As necessary, insert lines to echo the values of the vars you're working with. hth |
|
|||
|
Re: Login Script problems
Ok i commeneted out the header so it would allow me to see whats going on.
i have found two things first Parse error: parse error, unexpected T_IF, expecting ',' or ';' in c:\program files\easyphp1-7\www\assesment\login.php on line 51 then i commented out that if statement then i got this which i found very weird Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\program files\easyphp1-7\www\assesment\login.php on line 30 please ingore the t_if fixed that fault myself it is the mysql_num_rows that is causing the problem by not getting the number of rows it finds so meaning even when there a valid login it sees none but i do not get why num_rows is not working Last edited by as22607; May 10th, 2007 at 21:37. |
|
|||
|
Re: Login Script problems
Quote:
i have now finally debugged it and it works fine |
![]() |
| Tags |
| script error |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| login script | mbarr | Databases | 13 | Mar 12th, 2008 03:39 |
| Login Script Problem | Aaron1988 | PHP Forum | 5 | Nov 20th, 2006 06:15 |
| login script help | Aaron1988 | PHP Forum | 2 | Oct 25th, 2006 15:03 |
| Simple PHP login script help | Aaron1988 | PHP Forum | 7 | Aug 23rd, 2006 23:38 |
| Login Script... something wrong! | snowangel | PHP Forum | 6 | Mar 6th, 2006 15:27 |