Advertisement
Guest User

PHP code problem

a guest
Jul 14th, 2012
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.14 KB | None | 0 0
  1.  <?php
  2.  function main($formUse = true)
  3.  {
  4. $link = mysql_connect('bondsolutionsnjcom.fatcowmysql.com', 'lightswitch', '*password*');
  5. if (!$link) {
  6.     die('Could not connect: ' . mysql_error());
  7. }
  8. echo 'Connected successfully';
  9. mysql_select_db('red_light_life_accounts1');
  10.  
  11. // This could be supplied by a user, for example
  12. $username;
  13. $password;
  14.  
  15. if(!$username || !$password) {
  16.  
  17.     echo "Login or password cant be empty.";
  18.  
  19. } else {
  20.  
  21.     $SQL = "SELECT * FROM accounts WHERE username = '$username' & password = '$password'";
  22.  
  23.         $result_id = @mysql_query($SQL) or die("DATABASE ERROR!");
  24.  
  25.         $total = mysql_num_rows($result_id);
  26.  
  27.         if($total >= 1) {
  28.  
  29.             $datas = @mysql_fetch_array($result_id);
  30.            
  31.             $count = strlen($password);
  32.             $count2 = strlen($datas['passwird']);
  33.  
  34.             if(!strcmp($count, $count2)) {
  35.  
  36.                 echo "Success";
  37.  
  38.             } else {
  39.  
  40.                 echo "Username or password is wrong.";
  41.  
  42.             }
  43.  
  44.         } else {
  45.  
  46.             echo "Data invalid - cant find username.";
  47.  
  48.         }
  49.  
  50.     }
  51.  }
  52.  
  53. // Close mySQL Connection
  54.  
  55. mysql_close();
  56. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement