Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- ?>
- <?php
- $DB_SERVER="localhost";
- $DB_USER="root";
- $DB_PASS="new_password";
- $DB_NAME="userlistdb";
- $link=mysqli_connect($DB_SERVER,$DB_USER,$DB_PASS,$DB_NAME);
- if(isset($_SESSION["session_username"])){
- header("Location: intropage.php");
- }
- if(isset($_POST["login"])){
- if(!empty($_POST['username']) && !empty($_POST['password'])) {
- $username=htmlspecialchars($_POST['username']);
- $password=htmlspecialchars($_POST['password']);
- //var_dump($_POST);
- $query=mysqli_query($link,"SELECT * FROM usertbl WHERE username='".$username."' AND password='".$password."'");
- //print_r($query);
- $numrows=mysqli_num_rows($link,$query);
- print_r($numrows);
- if($numrows!=0)
- {
- while($row=mysqli_fetch_assoc($query))
- {
- $dbusername=$row['username'];
- $dbpassword=$row['password'];
- var_dump($row);
- }
- /*echo $dbusername;
- echo $dbpassword;
- echo $username;
- echo $password;
- */
- if($username == $dbusername && $password == $dbpassword)
- // if (true)
- {
- $_SESSION['session_username']=$username;
- header("Location: intropage.php");
- }
- } else {
- echo "Invalid username or password!";
- }
- } else {
- $message = "All fields are required!";
- }
- }
- ?>
- <?php include("includes/header.php"); ?>
- <div class="container mlogin">
- <div id="login">
- <h1>Вход</h1>
- <form action="" id="loginform" method="post"name="loginform">
- <p><label for="user_login">Имя опльзователя<br>
- <input class="input" id="username" name="username"size="20"
- type="text" value=""></label></p>
- <p><label for="user_pass">Пароль<br>
- <input class="input" id="password" name="password"size="20"
- type="password" value=""></label></p>
- <p class="submit"><input class="button" name="login"type= "submit" value="Log In"></p>
- <p class="regtext">Еще не зарегистрированы?<a href= "regg.php">Регистрация</a>!</p>
- </form>
- </div>
- </div>
- <?php include("includes/footer.php"); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement