Fungsi Simple PHP Secure Login & Remove Directory Rekursif

PHP Secure Login

Kadang kala kita bingung n cemas untuk sistem login kita. Kita takut ada serangan semacam SQL injection pada web yang kita buat. Banyak orang2 tidak bertanggung jawab dengan memasukkan querry di HTML Header kita. Oleh karena itu kita perlu membuat sistem login yang aman namun simple. Di bawah ini aku share aja cara login sistem yang pernaha aku buat, kalau ada kelemahan n kekurangan mohon saran n perbaikan, aku juga masih belajar,
session_start();
$nama_halaman=”.: L O G I N :.”;
$passwd=$_POST[password];
$user_post=$_POST[usernya];
if (empty($passwd) or empty($user_post))
{
// echo “tes”;
header(“location:login2.php”);
}
else
{
include(“../config.inc.php”);

$cari = array (“‘#’si”,
“‘<script[^>]*?>.*?</script>’si”, //INI ADALAH FUNGSI UNTUK MENCARI TAG HTML
“‘<[\/\!]*?[^<>]*?>’si”,
“‘([\r\n])[\s]+'”,
“‘&(quot|#34);’i”,
“‘&(amp|#38);’i”,
“‘&(lt|#60);’i”,
“‘&(gt|#62);’i”,
“‘&(nbsp|#160);’i”,
“‘&(iexcl|#161);’i”,
“‘&(cent|#162);’i”,
“‘&(pound|#163);’i”,
“‘&(copy|#169);’i”,
“‘&#(\d+);’e”);

$ganti = array (“”, //INI ADALAH FUNGSI UNTUK MEREPLACE TAG HTML
“”,
“\\1”,
“\””,
“&”,
“<“,
“>”,
” “,
chr(161),
chr(162),
chr(163),
chr(169),
“chr(\\1)”);

$usernya = preg_replace($cari, $ganti, $user_post);
$passwordnya = preg_replace($cari, $ganti, $passwd);

2 thoughts on “Fungsi Simple PHP Secure Login & Remove Directory Rekursif

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s