Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_GET['log'])){
- session_start();
- session_destroy();
- }
- $conn = mysqli_connect( "localhost","root","","mydb");
- $username = isset($_POST["username"]) ? $_POST["username"] : '';
- $password = isset($_POST["password"]) ? $_POST["password"] : '';
- $password = md5($password);
- if($username!='' and $password!=''){
- $sql = mysqli_query($conn, "SELECT * from user WHERE username = '$username' AND password = '$password' limit 1");
- $data = mysqli_fetch_assoc($sql);
- if($data){
- session_start();
- $_SESSION['username'] = $data['username'];
- $_SESSION['password'] = $data['password'];
- }
- if(isset($_SESSION["username"])){
- header('Location: index.php');
- }
- else {
- echo "<script type='text/javascript'>
- alert('Gagal login. periksa username dan password anda..!!!');
- </script>";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement