Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- This is the login.php
- <?php
- require 'addons/config.php';
- session_start();
- if(isset($_POST['submit'])){
- $username = $_POST['username'];
- $username = mysqli_real_escape_string($conn, $username);
- $password = $_POST['password'];
- $password = mysqli_real_escape_string($conn, $password);
- $query = "SELECT * FROM users WHERE username='$username' AND password='".md5($password)."'";
- $result = mysqli_query($conn, $query) or die (mysqli_error());
- $rows = mysqli_num_rows($result);
- if($rows==1){
- $_SESSION['username'] = $username;
- $_POST['email'] = $email;
- header("location: dashboard/home.php");
- }else{
- header("location: error/log_error.php");
- }
- }
- ?>
- <button onclick="document.getElementById('id02').style.display='block'" style="width:auto;">Login</button>
- <div id="id02" class="modal">
- <form class="modal-content animate" action="#" method="post">
- <div class="container">
- <label><b>Username</b></label>
- <input type="text" placeholder="Enter Username" name="username" required>
- <label><b>Password</b></label>
- <input type="password" placeholder="Enter Password" name="password" required>
- <button type="submit" name="submit" value="login">Login</button>
- <input type="checkbox" checked="checked"> Remember me
- </div>
- <div class="container" style="background-color:#f1f1f1">
- <button type="button" onclick="document.getElementById('id02').style.display='none'" class="cancelbtn">Cancel</button>
- </div>
- </form>
- </div>
- <script>
- // Get the modal
- var modal = document.getElementById('id02');
- // When the user clicks anywhere outside of the modal, close it
- window.onclick = function(event) {
- if (event.target == modal) {
- modal.style.display = "none";
- }
- }
- </script>
- <?php
- include '../addons/config.php';
- include ('../inc/auth.php');
- ?>
- <p>Welcome back <?php echo $_SESSION['username']; ?>!</p>
- <p>Your email is <?php echo $_POST['email']; ?>!</p>
- <a href="../addons/logout.php">Log off</a>
- <?php
- session_start();
- if(!isset($_SESSION["username"])){
- header("Location: ../index.php");
- exit();
- }
- ?>
- <?php
- #
- // Create connection
- $conn = mysqli_connect("localhost", "root", "", "database");
- // Check connection
- if($conn->connect_error){
- die("Can`t connect to database: " . $conn->connect_error);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement