Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Database connection
- require_once('dashboard/config/connection.php');
- session_start();
- //If the user has submitted the form
- if(isset($_REQUEST['username'])){
- //protect the posted value then store them to variables
- $username=mysqli_real_escape_string($dbc,$_POST['username']);
- $password=mysqli_real_escape_string($dbc,md5($_POST['password']));
- //Check if the username or password boxes were not filled in
- if(!$username || !$password){
- //if not display an error message
- echo "<center>You need to fill in a <b>Username</b> and a <b>Password</b>!</center>";
- }else{
- $username=mysqli_real_escape_string($dbc,$_POST['username']);
- $password=mysqli_real_escape_string($dbc,md5($_POST['password']));
- //Creating Session user
- $_SESSION['user']= $username;
- $qry="SELECT username, password FROM users
- WHERE username='$username'
- AND password='$password';";
- $r=@mysqli_query($dbc,$qry);
- $row=@mysqli_num_rows($r);
- $rows=@mysqli_fetch_array($r,MYSQLI_ASSOC);
- if($row<=0){
- echo "<div class='isa_warning'>Check your Username and/ or Password and Try again.</div>";
- }
- else{
- $qrys="SELECT username, user_id, type FROM users WHERE username='$username'";
- $rs=@mysqli_query($dbc,$qrys);
- $rws=@mysqli_num_rows($rs);
- $rw=@mysqli_fetch_array($rs,MYSQLI_ASSOC);
- $_SESSION['type']=$rw['type'];
- $_SESSION['user_id']=$rw['user_id'];
- if($rws<=''){
- echo "<div class='isa_warning'>You do not have rights to access the system, Please contact the Administrator </div>";
- }else{
- $user_group=$rw['type'];
- $_SESSION['user_group']=$user_group;
- $_SESSION['user'] = $rw['username'];
- $_SESSION['type'] = $user_group;
- echo $user_group;
- }
- }
- }
- exit();
- }
- ?>
- <div id="isa_warning"></div>
- <form id="loginForm" method="post" name="login" action="index.php">
- <label for="username">Email:</label>
- <input type="text" id="username" required name="username">
- <label for="password">Password:</label>
- <input type="password" id="password" required name="password">
- <div id="lower">
- <input type="submit" value="Login">
- </div><!--/ lower-->
- </form>
- <script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
- <script type="text/javascript">
- $( "#loginForm" ).submit(function( event ) {
- //var dataToSend = 'username='+$("input[name^='username']").val()+'&password='+$("input[name^='password']").val();
- var url = 'index.php';
- $.ajax({
- type: "POST",
- url: url,
- data: $( "#loginForm" ).serialize(),
- success: function(response){
- alert(response);
- if (data == "success") {
- window.location = 'dashboard.php';
- }
- else{
- $("#isa_warning").html(response);
- }
- }
- });
- event.preventDefault();
- });
- </script>
- <script>
- (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
- (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
- m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
- })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
- ga('create', 'UA-55238160-10', 'auto');
- ga('send', 'pageview');
- </script>
- <?php
- include("common/menu.php");
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>::: My Homework :::</title>
- <meta name="description" content="We engage in high quality writing of essays, term papers, research papers, thesis papers, dissertations, book reviews, book reports, speeches, assignments, business papers and web content. We are a real-time freelancing service out to efficiently deliver work. We provide high-quality papers written from scratch to our customers to suit their needs whenever, wherever; papers are plagiarism free, and on time.">
- <meta name="keywords" content="writing, essays, term papers, research papers, business papers, speeches, plagirism free">
- <meta name="robots" content="index, nofollow">
- <meta name="web_author" content="samuel, shammir">
- <meta name="language" content="english">
- <!--
- Template 2033 Business
- http://www.tooplate.com/view/2033-business
- -->
- <!-- Global site tag (gtag.js) - Google Analytics -->
- <script async src="https://www.googletagmanager.com/gtag/js?id=UA-107952008-1"></script>
- <script>
- window.dataLayer = window.dataLayer || [];
- function gtag(){dataLayer.push(arguments);}
- gtag('js', new Date());
- gtag('config', 'UA-107952008-1');
- </script>
Add Comment
Please, Sign In to add comment