Advertisement
Guest User

Untitled

a guest
May 9th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.29 KB | None | 0 0
  1. <?php
  2.  
  3. // Edit your mssql info here
  4. // BEGIN MSSQL INFO
  5. $CONFIG['host'] = "localhost";
  6. $CONFIG['user'] = "sa";
  7. $CONFIG['pass'] = "server";
  8. // END MSSQL INFO
  9.  
  10. //----------------------------- DO NOT EDIT ANYTHING BELOW HERE !!!!! ------------------------------------
  11.  
  12. $CONFIG['conn']  = mssql_connect( $CONFIG['host'], $CONFIG['user'], $CONFIG['pass']);
  13.  
  14. function anti_injection($sql) {
  15.    $sql = preg_replace(sql_regcase("/(from|select|insert|delete|where|drop table|show tables|#|\*|--|\\\\)/"),"",$sql);
  16.    $sql = trim($sql);
  17.    $sql = strip_tags($sql);
  18.    $sql = addslashes($sql);
  19.    return $sql;
  20. }
  21. //----------------------------------------------------------------------------------------------------------
  22.  
  23. if(isset($_GET['action']) && ($_GET['action'] == "login")){
  24.  
  25.         $user = anti_injection($_POST['user']);
  26.         $pass = anti_injection($_POST['pass']);
  27.         $crypt_pass = md5($pass);
  28.                
  29.         $result1 = mssql_query("SELECT * FROM account.dbo.user_profile WHERE user_id = '".$user."'");
  30.         $count1 = mssql_num_rows($result1);
  31.  
  32.         $result2 = mssql_query("SELECT user_pwd FROM account.dbo.user_profile WHERE user_id = '".$user."'");
  33.         $row2 = mssql_fetch_row($result2);
  34.  
  35.         if($count1 == '0') {
  36.                 echo '<br>This game account is not found in the database.';
  37.         }
  38.         elseif($row2[0] != $crypt_pass) {
  39.                 echo '<br>Wrong password. Try again.';
  40.         }
  41.         elseif($_GET['login'] != 'login' && $count1 == '0') {
  42.                 echo '<br>Login Error, Please login again.';
  43.         } else {
  44.        
  45.         // Begin secure content
  46.                 $_SESSION['user'] = $user;
  47.                 echo "<h3>Welcome, ".$_SESSION['user']."</h3>";
  48.                 echo "<br>";
  49.                 echo "Your content here";
  50.         // Dont forget to and your session
  51.         // session_destroy();
  52.         // End secure content
  53.         }
  54. } else {
  55.  
  56. echo '<h2>Login here</h2><br />
  57.        <form name="" action="'.$_SERVER['php_self'].'?action=login" method="post">
  58.                Name: <input type="text" name="user" maxlength="16"><br />
  59.                Password: <input type="password" name="pass" maxlength="16"> <br />
  60.                <input type="submit" value="Login!">
  61.        </form>';
  62. }
  63. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement