Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » What did I get wrong in this php code?
Closed Thread
Old 11-26-2007, 12:23 PM   #1 (permalink)
 
Super Techie

Join Date: Sep 2006

Location: Altoona, PA

Posts: 255

Mike9182 is on a distinguished road

Default What did I get wrong in this php code?

I'm new to php, especially databases, so this code probably contains a lot of errors. I amt trying to check the username and password from a form on the previous page. When this code runs nothing comes up, and everything that is written after the php code does not appear in the source.


PHP Code:
<?php
//Connect To Database
$hostname='removed for security reasons';
$username='removed for security reasons';
$password='removed for security reasons';
$dbname='Main9182';
$usertable='user';
$user $_POST["user"] ;
$pass $_POST["pass"] ;

mysql_connect($hostname,$username$password) OR DIE ('Unable to connect to database! Please try again later.');
mysql_select_db($dbname);

//Check Username
$query 'SELECT Username FROM $usertable';
$result mysql_query($query);
while(
$result $user) ;
    {
    
$queryp 'SELECT Password FROM $usertable' ;
    
$presult mysql_query($queryp) ;
    
    
//Check Password
    
while($presult $pass) ;
        {
        
setcookie("access""Yes"time()+3600);
        echo 
"Login successful, click" ;
        echo 
"<a href='news-edit.php'>here</a>" ;
        echo 
"to continue" ;
        echo 
"<SCRIPT LANGUAGE='JavaScript'>" ;
        echo 
"<!--" ;
        echo 
"windows.location='news-edit.php ;" ;
        echo 
"// -->" ;
        echo 
"</script>" ;
        }
    
    while(
$presult !=  $pass) ;
        {
        echo 
"incorrect username or password, please" ;
        echo 
"<a href='login.php'>retry</a>" ;
        }
    }
while(
$result != $user) ;
    {
    echo 
"incorrect username or password, please" ;
    echo 
"<a href='login.php'>retry</a>" ;
    }
?>

__________________

My Comp:
Antec 900
Gigabyte DS3
EVGA 8800GTS (G92)
Antec TruPower 650 watt psu
Core 2 Duo E6700 @ 3.3Ghz
G.Skill 4GB DDR2-800
2 x Seagate Barracuda 250GB HDD in RAID 0
1 x Seagate Barracuda 500GB HDD
ACER 19" 5ms monitor
ZALMAN CNPS9500 cpu fan/heatsink

Last edited by Mike9182; 11-26-2007 at 12:27 PM.
Mike9182 is offline  
Old 11-28-2007, 04:35 PM   #2 (permalink)
 
Super Techie

Join Date: Sep 2006

Location: Altoona, PA

Posts: 255

Mike9182 is on a distinguished road

Default Re: What did I get wrong in this php code?

I figured out what I did wrong myself, I used "while" as an "if..else" statement.
__________________

My Comp:
Antec 900
Gigabyte DS3
EVGA 8800GTS (G92)
Antec TruPower 650 watt psu
Core 2 Duo E6700 @ 3.3Ghz
G.Skill 4GB DDR2-800
2 x Seagate Barracuda 250GB HDD in RAID 0
1 x Seagate Barracuda 500GB HDD
ACER 19" 5ms monitor
ZALMAN CNPS9500 cpu fan/heatsink
Mike9182 is offline  
 
Closed Thread

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Php Code Help tiger Programming Discussions 1 10-25-2007 07:26 AM
What's wrong in this C++ code Mike9182 Programming Discussions 6 10-15-2007 04:25 PM
PHP code needed Syphanx Programming Discussions 7 05-15-2007 03:03 PM
PHP 2-player game? thejeremy Programming Discussions 4 04-09-2007 05:01 PM
Remote file access w/ IP + PHP? thejeremy Programming Discussions 2 04-04-2007 04:24 PM