Advertisement
aproxtime

Masuk-2

Jul 30th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.12 KB | None | 0 0
  1.  <?php
  2. session_start();
  3. if(!empty($_SESSION['user'])){
  4. header('Location: forum.php');
  5. }
  6. ?>
  7.         <div class="myform">
  8.                 <div class="container">
  9.                 <div class="halaman">
  10.  
  11.                     <div class="col-md-12" >
  12.                     <h2>MASUK</h2>
  13.                     </div>
  14.                 </div>
  15.                 </div>
  16.                 <div class="container">
  17.                         <form action="" method="post">
  18.                 <div class="col-md-12">
  19.                     <input type="text" placeholder="Username" name="email">
  20.                 </div>
  21.                 <div class="col-md-12">
  22.                     <input type="password" placeholder="Password" name="password">
  23.                 </div>
  24.                 <div class="col-md-12">
  25.                     <input type="submit" value="MASUK" name="login">
  26.                 </div>
  27.             </form>
  28.                         <?php
  29.  
  30.                         if(!empty($_POST['login'])){
  31.  
  32.                         $email = $_POST['email'];
  33.                         $password = $_POST['password'];
  34.  
  35.                         $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());
  36.                         $data = mysql_fetch_array($sql);
  37.                         $cek = mysql_num_rows($sql);
  38.  
  39.                         if ($cek >= 1) {
  40.                                         $_SESSION['user'] = $data['id_user'];
  41.                                         echo "<script>alert('Anda Login dengan akun ".$email."');</script>";
  42.                                         echo "<script>window.location.href = 'index.php?p=forum';</script>";
  43.                                        
  44.                         } else {
  45.                                         echo "Email Atau Password Anda Salah!";
  46.                                         echo " Tidak Punya Akun? <a href='?p=gabung'><h2>Register</h2></a>";
  47.                         }
  48.                         }
  49.                         ?>
  50.                 </div>
  51.         </div>
  52.  
  53.     </main>
  54.     <!-- main page ends -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement