Re: Functions are driving me crazy....

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



<?PHP
/// initialize the return variable
$authenticated = false;

       function authentication(){
               if(!isset($user) || !isset($pass)) { return false; }  /// <--
i would do it a bit nicer than this, but you get the idea

               if($user && $pass) { // Keep in mind, PASSWORD has meaning in
MySQL
                       // Do your string sanitizing here
                       // (e.g. - $user = mysql_real_escape_string($
_POST['user']);)
                       $loginQuery = "SELECT * FROM login WHERE
user='".$user."' AND
Userpass='".$pass."' LIMIT 0,1;";
                       $loginResult = mysql_query($loginQuery) or die("Wrong
data supplied
or database error"  .mysql_error());
                       while($row1 = mysql_fetch_array($loginResult)) {
                               $_SESSION['user'] = $row1['User'];
                               $_SESSION['loggedin'] = "YES";
                               $authenticated = "true";
                       }
               }
       }return $authenticated;
?>

-nathan

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux