Advertisement
Guest User

Fixed

a guest
Jul 21st, 2012
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!-- This Is To Call Username/Password -->
  2.  
  3. <!--
  4.     <form method="post" action="#" id="login">
  5.         <input type="text" name="username" id="username" />
  6.         <input type="password" name="password" id="password" />
  7.         <input type="submit" value="Login" id="submit" />
  8.     </form>
  9. -->
  10. <?php
  11.  function main($formUse = true)
  12.  {
  13. $link = mysql_connect('bondsolutionsnjcom.fatcowmysql.com', 'lightswitch', '*password*');
  14. if (!$link) {
  15.     die('Could not connect: ' . mysql_error());
  16. }
  17. echo 'Connected successfully';
  18. mysql_select_db('red_light_life_accounts1');
  19.  
  20. // This could be supplied by a user, for example
  21.  
  22. $username = $_POST['username']; //Called By The Post, $_POST Is the Global variable to use
  23. $password = $_POST['password']; //Called By The Post, $_POST Is the Global variable to use
  24. $errors = array();
  25.  
  26. if(isset($POST['submit'])){
  27.     if(!$username){
  28.         $errors[] = "Username Can Not Be Empty";
  29.     }
  30.     if(!$password){
  31.         $errors[] = "Password Can Not Be Empty";
  32.     }
  33. }
  34.  
  35. $dothis = count($errors);
  36.  
  37. if($dothis = 0){
  38.     $SQL = "SELECT * FROM accounts WHERE username = '$username' & password = '$password'";
  39.         $result_id = @mysql_query($SQL) or die("DATABASE ERROR!");
  40.         $total = mysql_num_rows($result_id);
  41.         if($total >= 1) {
  42.             $datas = @mysql_fetch_array($result_id);
  43.                         $count = strlen($password);
  44.                         $count2 = strlen($datas['passwird']);
  45.             if(!strcmp($count, $count2)) {
  46.                 echo "Success";
  47.             } else {
  48.                 echo "Username or password is wrong.";
  49.             }
  50.         } else {
  51.  
  52.             echo "Data invalid - cant find username.";
  53.  
  54.         }
  55.  
  56.     }else{
  57.         foreach($errors as $display){
  58.             echo $display;
  59.         }
  60.     }
  61.  }
  62.  
  63. // Close mySQL Connection
  64.  
  65. mysql_close();
  66. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement