Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
While Clause Failure ??? WTF help
Old 09-23-2007, 08:14 PM While Clause Failure ??? WTF help
amw_drizz's Avatar
Ultra Talker

Posts: 340
Name: Jon
Location: New York
Trades: 0
okay some issues been a while since i wrote php or been on this site for that matter.

I am working on a login system for my users and my while clause is failing and the way the page is templated wont display an error if i put
PHP Code:
or die(mysql_error()) 
at the end of it here is the snippet

PHP Code:

$res 
"SELECT * FROM users WHERE usrnm='"$usr ."'";
$subres mysql_query($res) or die('FAIL1');
while(
$usrtst mysql_fetch_array$subres ) or die('FAIL2')) {
        if(
$pwd == !$usrtst['pwd']){
            echo 
'<form method="post" action="/scripts/doLogin.php">
           <div align="center" class="style69">
             <p>Quick Login:<br />
               Username<br />
                   <input name="username" type="text" id="username" />
                     <br />
               <strong><font color="#FF0000">Password is Invalid </font></strong><br />
               <input name="password" type="password" id="password" />
               <br />
               <input type="submit" name="Submit" value="Submit" />
               <br />
               <input name="remberme" type="checkbox" id="remberme" value="yes" />
             Remember Me </p>
             </div>
        </form> '
;
        } 
though testing i found it was this line failing (notice or die('FAIL2')) yet this script works on my login processor so i dont know were i am going wrong, as this script is checking a cookie for a user name and password, check the username against the db, then validates if the pass is correct or not if it is then continues and if it fails then it redisplays the form with bold red font face to indicate a bad password in the cookie (ie someone spoofed or tampered it)

hope that helps with details thanks in advance for the help
__________________
AMW_Drizz
Dev Machine:: Apache 2.2.6 PHP 5.2.6 MySQL 5.1

Last edited by amw_drizz; 09-23-2007 at 08:17 PM.. Reason: forgot something ;)
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
 
Register now for full access!
Old 09-23-2007, 09:04 PM Re: While Clause Failure ??? WTF help
amw_drizz's Avatar
Ultra Talker

Posts: 340
Name: Jon
Location: New York
Trades: 0
figuered it out by doing some more research in to mysql commands for php

i changed this
PHP Code:
while($usrtst mysql_fetch_array$subres ) or die('FAIL2')) { 
to this
PHP Code:
while($usrtst mysql_fetch_row$subres )) { 
Um nevermind didnt work, forgot to test completly and it failed.... AGAIN...
__________________
AMW_Drizz
Dev Machine:: Apache 2.2.6 PHP 5.2.6 MySQL 5.1

Last edited by amw_drizz; 09-23-2007 at 09:07 PM..
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
Old 09-25-2007, 01:16 PM Re: While Clause Failure ??? WTF help
Junior Talker

Posts: 3
Name: Joe
Trades: 0
I think it's missing a '}'. You are closing the if, but not the while.

Hi, this my first post
mrSnacks is offline
Reply With Quote
View Public Profile
 
Old 09-25-2007, 06:10 PM Re: While Clause Failure ??? WTF help
amw_drizz's Avatar
Ultra Talker

Posts: 340
Name: Jon
Location: New York
Trades: 0
figured it out, finally

my dumb self had set the db user and password vars the same as the vars called from the cookie but had the require_once listing after calling the vars, so instead of using the vars from the cookie it used the vars from the config file, so i changed the config file to use different vars so instead of $usr i changed it to $dbusr.

works now
__________________
AMW_Drizz
Dev Machine:: Apache 2.2.6 PHP 5.2.6 MySQL 5.1
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
Old 09-25-2007, 07:19 PM Re: While Clause Failure ??? WTF help
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
you are storing an user/password in a cookie !!!???
NAUGHTY !!!!!
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 09-25-2007, 07:21 PM Re: While Clause Failure ??? WTF help
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Quote:
Originally Posted by tripy View Post
you are storing an user/password in a cookie !!!???
NAUGHTY !!!!!
He's right... thats a bad idea.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 09-26-2007, 03:29 PM Re: While Clause Failure ??? WTF help
amw_drizz's Avatar
Ultra Talker

Posts: 340
Name: Jon
Location: New York
Trades: 0
the password is only stored if the user checks remberme then when it is stored in the cookie it is stored in its MD5 state and the cookies are set to expire in 8 hrs

the connection between server is https and it is on an internal, i will rewrite the login to require users to enter the password everytime the site is loaded in to the browser after i am done making it, as it would be annoying everytime i close the browser (accidently or on purpose) to reenter the password esp if the page dont load correctly or i am debugging it.
__________________
AMW_Drizz
Dev Machine:: Apache 2.2.6 PHP 5.2.6 MySQL 5.1
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
Reply     « Reply to While Clause Failure ??? WTF help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.26447 seconds with 12 queries