Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- if(!empty($_SESSION['user'])){
- header('Location: forum.php');
- }
- ?>
- <div class="myform">
- <div class="container">
- <div class="halaman">
- <div class="col-md-12" >
- <h2>MASUK</h2>
- </div>
- </div>
- </div>
- <div class="container">
- <form action="" method="post">
- <div class="col-md-12">
- <input type="text" placeholder="Username" name="email">
- </div>
- <div class="col-md-12">
- <input type="password" placeholder="Password" name="password">
- </div>
- <div class="col-md-12">
- <input type="submit" value="MASUK" name="login">
- </div>
- </form>
- <?php
- if(!empty($_POST['login'])){
- $email = $_POST['email'];
- $password = $_POST['password'];
- $sql = mysql_query("SELECT m.email, m.password FROM tb_user m WHERE m.email= '$email' AND m.password=md5('$password')") or die(mysql_error());
- $data = mysql_fetch_array($sql);
- $cek = mysql_num_rows($sql);
- if ($cek >= 1) {
- $_SESSION['user'] = $data['id_user'];
- echo "<script>alert('Anda Login dengan akun ".$email."');</script>";
- echo "<script>window.location.href = 'index.php?p=forum';</script>";
- } else {
- echo "Email Atau Password Anda Salah!";
- echo " Tidak Punya Akun? <a href='?p=gabung'><h2>Register</h2></a>";
- }
- }
- ?>
- </div>
- </div>
- </main>
- <!-- main page ends -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement