|
| |||||||
![]() | Welcome to iWEBTOOL Talk, where you talk about
webmaster-related stuff.
1 Register
2 Browse the board
3 Discuss whatever may interest you! | |||||||||||||
![]() |
| | Thread Tools | Search this Thread | Display Modes |
| | #1 |
| Newcomer Join Date: Nov 2007
Posts: 13
![]() | I've been having some trouble with my loggin script (bellow). It never finds the password out of the databasse so it eather always takes the if in the if.. else or the else indiferent to what the input password is. Could anyone help me...? <?php $username="LordOrange"; $con = mysql_connect("mysql3.freehostia.com","benmivl61_m y data","LordRocks"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("benmil61_mydata", $con); $result = mysql_query("SELECT * FROM reviews WHERE usernames='LordOrange'"); while($row = @mysql_fetch_array($result)) { echo $row["password"]; } $password = $row["password"]; echo $password . "<br>"; echo $_POST["password"] . "<br>"; if ($password == $_POST["password"]) echo "<a href='movies-edit.php'>Continue</a>"; else echo "Incorrect username or password"; ?> Last edited 11-10-2007 at 06:47 AM. |
| |
|
| |||||||
| | #2 | |
| Moderator Join Date: Aug 2006
Posts: 1,134
![]() ![]() ![]() ![]() ![]() | The while loop is try this Quote:
__________________ Webmaster Resources & Forums / Webmaster Tools & Forum / eCommerce Shopping Basket / Scene Releases | |
| |
| | #3 |
| Newcomer Join Date: Nov 2007
Posts: 13
![]() | It still goes with the else statement the whole time and isn't writing anything for the password from the database. |
| |
| | #4 |
| Moderator Join Date: Aug 2006
Posts: 1,134
![]() ![]() ![]() ![]() ![]() | lets see the database whats the point of the while loop? It loops to the last password ![]()
__________________ Webmaster Resources & Forums / Webmaster Tools & Forum / eCommerce Shopping Basket / Scene Releases |
| |
| | #5 |
| Newcomer Join Date: Nov 2007
Posts: 13
![]() | The loop was just the only way I could get it to work |
| |
| | #6 |
| Senior Member | The loop is correct. I would recommend not doubling up on variable names even though they are in different scopes (post and local) - in other words, $_POST['password'] and $password is a bad idea, especially with register_globals on. It looks like that setting IS on and thus $password ALWAYS == $password. Rename your variables.
__________________ Intripita :: web hosting | development | conferencing Business-Grade Web Hosting, Professional Conferencing, Effective Web Development by Intripita |
| |
| | #7 |
| Newcomer Join Date: Nov 2007
Posts: 13
![]() | Thanks, I'll try that |
| |
| | #8 |
| Newcomer Join Date: Nov 2007
Posts: 13
![]() | It still alwys goes with the else code. It also doesn't echo $password. |
| |
| | #9 |
| Newcomer Join Date: Nov 2007
Posts: 13
![]() | This is my code now Code:
Last edited 11-11-2007 at 05:21 AM. |
| |
| | #10 |
| Newcomer Join Date: Nov 2007
Posts: 13
![]() | I found my problem.... My $row variable wasn't global so I could only use it in the scope of the while loop |
| |
(Threads which have no activity for more than 30 days are automatically closed.) |
| Quick Reply | ||
|
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Time to recall your old friends. | Webdomain.com | Web Hosting | 0 | 07-10-2007 10:46 PM |
| What? No SQL Section? | selectsplat | Programming | 3 | 06-14-2007 02:08 AM |
| Looking for PHP+SQL programmer | Rickzkm | PHP | 6 | 04-29-2007 05:23 AM |
| Pet Deaths Prompt Recall of Pet Food | lexmarks567 | General Talk | 4 | 03-19-2007 11:07 AM |
| Sql ? | pankaj | MySQL | 5 | 03-15-2007 08:14 PM |