Advertisement
Guest User

Untitled

a guest
Jul 4th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. <?php
  2. session_start();
  3. if (headers_sent()){
  4. die("Redirect failed. Please click on this link:". '<a href="http://digyourbrain.org/admin/dashboard.php">Dashboard</a>');
  5. }elseif(isset($_SESSION['username'])){
  6. header("location:dashboard.php");}
  7. if(isset($_POST['submit'])){
  8. $username=mysqli_real_escape_string($con,$_POST['username']);
  9. $pass=mysqli_real_escape_string($con,$_POST['password']);
  10. $password = md5($_POST['password']);
  11. $password=mysqli_real_escape_string($con,$password);
  12. $user=mysqli_query($con,"SELECT * FROM user WHERE username='$username' and password='$password' and status='active' limit 1");
  13. $users=mysqli_fetch_array($user);
  14. $countuser=mysqli_num_rows($user);
  15. $username=$users['username'];
  16. if(empty($username)){
  17. $error="Username missing";
  18. }elseif(empty($pass)){
  19. $error="Password missing";
  20. }elseif($countuser==1){
  21. $_SESSION['username']=$username;
  22. header("location:dashboard.php");
  23. exit();
  24. }else{
  25. $error="Invalid username or password!";
  26. }
  27. }
  28. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement