Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //include('login.php'); // Includes Login Script
- session_start(); // Starting Session
- $error=''; // Variable To Store Error Message
- if (isset($_POST['submit'])) {
- if (empty($_POST['username']) || empty($_POST['password'])) {
- $error = "Username or Password is invalid";
- }
- else
- {
- // Define $username and $password
- $username=$_POST['username'];
- $password=$_POST['password'];
- // Establishing Connection with Server by passing server_name, user_id and password as a parameter
- $connection = mysql_connect("localhost", "Database", "Password");
- // To protect MySQL injection for Security purpose
- $username = stripslashes($username);
- $password = stripslashes($password);
- $username = mysql_real_escape_string($username);
- $password = mysql_real_escape_string($password);
- // Selecting Database
- $db = mysql_select_db("julianme_Quick", $connection);
- // SQL query to fetch information of registerd users and finds user match.
- $query = mysql_query("select * from QuickFood_Werknemers where password='$password' AND username='$username'", $connection);
- $rows = mysql_num_rows($query);
- if ($rows == 1) {
- $_SESSION['login_user']=$username; // Initializing Session
- header("location: main.php"); // Redirecting To Other Page
- } else {
- $error = "Username or Password is invalid";
- }
- mysql_close($connection); // Closing Connection
- }
- }
- if(isset($_SESSION['login_user'])){
- header("location: main.php");
- }
- ?>
- <!DOCTYPE html>
- <html >
- <head>
- <meta charset="UTF-8">
- <title>Quick Company</title>
- <link href="https://fonts.googleapis.com/icon?family=Material+Icons"
- rel="stylesheet">
- <link href='https://fonts.googleapis.com/css?family=Roboto:400,500' rel='stylesheet' type='text/css'>
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
- <link rel="stylesheet" href="css/style.css">
- </head>
- <body>
- <div class="login-container">
- <section class="login" id="login">
- <header>
- <h2>Quick Company</h2>
- <h4>Login</h4>
- </header>
- <form class="login-form" action="" method="post">
- <input type="text" class="login-input" name="username" id="name" placeholder="User"/>
- <input type="password" class="login-input" name="password" id="password" placeholder="Password"/>
- <div class="submit-container">
- <button name="submit" type="submit" class="login-button">SIGN IN</button>
- </div>
- </form>
- </section>
- <p>2017 - <a href="https://www.twitter.com/x16julian16x">Julian Meurer</a></p>
- </div>
- <script src="js/index.js"></script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement