Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include "config/koneksi.php";
- $con=mysqli_connect("localhost","root","rootroot","ecom");
- if (isset($_POST['submit'])){
- function cek_form($cek){
- $filter = mysqli_real_escape_string($cek);
- return $filter;
- }
- $txtuser = mysqli_real_escape_string($con, $_POST['username']);
- $txtpass = mysqli_real_escape_string($con, md5($_POST['password']));
- if (empty($txtpass) || empty($txtuser)){
- echo "<script>alert('Username dan Password TIDAK BOLEH KOSONG!');</script>";
- }
- else{//cek alfabet
- if (!ctype_alnum($txtuser) OR !ctype_alnum($txtpass)){
- echo "<script>alert('Anda memasukan karakter yang salah');location='index.php?ref=login'</script>";
- }
- else{
- $login=mysqli_query($con, "select * from anggota where username='$txtuser' and password='$txtpass' ");
- $ketemu=mysqli_num_rows($login);
- $tampil=mysqli_fetch_array($login);
- //ada user
- if ($ketemu > 0){
- session_start();
- //daftar session
- //session_register("id_anggota");
- $_SESSION["id_anggota"] = $ketemu;
- //isi session
- $_SESSION['id_anggota']=$tampil['id_anggota'];
- echo"<meta http-equiv='refresh' content='0; url=index.php'>";
- }
- else{
- echo "<script>alert('Username atau Password Salah!');</script>";
- }
- }
- }
- }
- else{
- echo"<meta http-equiv='refresh' content='0; url=index.php'>";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement