Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- if (headers_sent()){
- die("Redirect failed. Please click on this link:". '<a href="http://digyourbrain.org/admin/dashboard.php">Dashboard</a>');
- }elseif(isset($_SESSION['username'])){
- header("location:dashboard.php");}
- if(isset($_POST['submit'])){
- $username=mysqli_real_escape_string($con,$_POST['username']);
- $pass=mysqli_real_escape_string($con,$_POST['password']);
- $password = md5($_POST['password']);
- $password=mysqli_real_escape_string($con,$password);
- $user=mysqli_query($con,"SELECT * FROM user WHERE username='$username' and password='$password' and status='active' limit 1");
- $users=mysqli_fetch_array($user);
- $countuser=mysqli_num_rows($user);
- $username=$users['username'];
- if(empty($username)){
- $error="Username missing";
- }elseif(empty($pass)){
- $error="Password missing";
- }elseif($countuser==1){
- $_SESSION['username']=$username;
- header("location:dashboard.php");
- exit();
- }else{
- $error="Invalid username or password!";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement