CaFc_Versace

Anti SQL Injection Login

Jun 28th, 2014
867
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.10 KB | None | 0 0
  1. <?php
  2. // ---------------------------- Anti SQL Injection Login © made by CaFc Versace ---------------------------- \\
  3. $inpohAing['host'] = "localhost";
  4. $inpohAing['user'] = "CaFc";
  5. $inpohAing['pass'] = "Versace";
  6. $inpohAing['conn'] = mssql_connect($inpohAing['host'], $inpohAing['user'], $inpohAing['pass']);
  7.  
  8. function aingAntiHek($SQLi) {
  9.     $SQLi = preg_replace(sql_regcase("/(from|union|select|order by|or|insert|delete|where|drop table|show tables|#|'|`|\"|\*|--|\\\\)/"), "", $SQLi);
  10.     $SQLi = trim($SQLi);
  11.     $SQLi = strip_tags($SQLi);
  12.     $SQLi = addslashes($SQLi);
  13.     return $SQLi;
  14. }
  15. //---------------------------------------------------------------------------------------------------------- \\
  16.  
  17. if (isset($_GET['action']) && ($_GET['action'] == "login")) {
  18.  
  19.     $userAing = aingAntiHek($_POST['user']);
  20.     $passAing = aingAntiHek($_POST['pass']);
  21.     $nyekrip  = md5($passAing);
  22.  
  23.     $hasil1   = mssql_query("SELECT * FROM account.dbo.user_profile WHERE user_id = '" . $userAing . "'");
  24.     $ngitung1 = mssql_num_rows($hasil1);
  25.  
  26.     $hasil2 = mssql_query("SELECT user_pwd FROM account.dbo.user_profile WHERE user_id = '" . $userAing . "'");
  27.     $baris2 = mssql_fetch_row($hasil2);
  28.  
  29.     if ($ngitung1 == '0') {
  30.         echo '<br>Akun Anda tidak ada dalam database.';
  31.     } elseif ($baris2[0] != $nyekrip) {
  32.         echo '<br>Kata sandi salah. Silahkan coba kembali.';
  33.     } elseif ($_GET['login'] != 'login' && $ngitung1 == '0') {
  34.         echo '<br>Login gagal, mohon login kembali.';
  35.     } else {
  36.  
  37.         //-------- KODEMU DISINI -------
  38.         $_SESSION['user'] = $userAing;
  39.         echo "<h3>Selamat datang " . $_SESSION['user'] . " piye kabare?</h3>";
  40.         echo "<br />";
  41.         //------------------------------
  42.     }
  43. } else {
  44.     echo '<h2>Login cok!</h2><br />
  45.          <form name="" action="' . $_SERVER['php_self'] . '?action=login" method="post">
  46.            Name: <input type="text" name="user" maxlength="16"><br />
  47.            Password: <input type="password" name="pass" maxlength="16"> <br />
  48.          <input type="submit" value="Login!">
  49.          </form>';
  50. }
  51. ?>
Advertisement
Add Comment
Please, Sign In to add comment