login not working

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pagegen
Forum Commoner
Posts: 32
Joined: Sat May 31, 2008 6:38 am

login not working

Post by pagegen »

Code: Select all

<?php
 
 
include("session.php");
include("connect.php");
            
    
    if (isset($_POST['txtName']) && isset($_POST['txtPass'])){
     
        $uname = strip_tags($_POST['txtName']);
        $upass = strip_tags($_POST['txtPass']);
          
     if(!is_resource($dbc)) {
            header ("Location: login.php?e=1");
         echo "Failed to connect to the server\n";
     }
     else {
       $queryL = sprintf("SELECT * FROM users WHERE username='$uname' AND password='$upass'", mysql_real_escape_string($uname, $dbc), mysql_real_escape_string($upass, $dbc));
        $resultL = mysql_query ($queryL);
    
        while($row = mysql_fetch_array($resultL,MYSQL_ASSOC))
 
         if (mysql_affected_rows($dbc) > 0) {
             
            setcookie ('username', $uname );
    setcookie ('userType', $row[userType] );
             
            header ("Location: default.php");
            //echo "do all the login stuff here now"; 
         }
         else {
                    header ("Location: login.php?e=2"); 
             //echo "the user has input incorrect details";
            }
        }
    }
  ?>
 
its very strand because it worked yesterday but sum reason it wont work now

any ideas guys
pagegen
Forum Commoner
Posts: 32
Joined: Sat May 31, 2008 6:38 am

Re: login not working

Post by pagegen »

can no1 help?
Post Reply