I
I
iddaurski_roma2018-03-27 12:46:58
User identification
iddaurski_roma, 2018-03-27 12:46:58

Problem with authorization on the site?


<?php
if ($error != "") {
echo $error."
";
}
?>
Username:
Password:
Remember me

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
iddaurski_roma, 2018-03-27
@iddaurski_roma

<?php 
  require_once 'Reg_OOP/includes/global.php';
  
  
  $error="";
  $username="";
  $password="";
  //
  if (isset($_POST['submit-login'])) {
    $username=$_POST['username'];
    $password=$_POST['password'];
    $userTools=new UserTools;
    if ($userTools->login($username, $password)) {
      header("Location: index.php");
    }
    $check_user = "SELECT * FROM users WHERE username = '{$username}' AND password = '{$password}'";
    $query = mysqli_query($db_connect, $check_user);
    
    
    if(mysqli_num_rows($query) >= 1){
      $_SESSION['username'] = $username;
      redirect_to('User.class.php');
      exit;
    } elseif(mysqli_num_rows($query) == 0){
      echo "Неверный логин или пароль";
      }
  }

 ?>
 <!DOCTYPE html>
 <html>
     <meta charset="utf-8">
 <head>
 	<title>Login</title>
 </head>
 <body>
 			
 	<?php 

 		if ($error != "") {
 			echo $error."<br/>";
 		}

 	 ?>
 	 <form class="form-signing" action="login.php" method="post">
 	 	Username: <input type="text" value="<?php echo $username; ?>" name="username"/><br><br>
 	 	Password: <input type="password" value="<?php echo $password; ?>" name="password"/><br><br>
 <div class="checkbox mb-3">
        <label>
          <input type="checkbox" value="remember-me"> Remember me
        </label>
      </div>
<!--
      <p>
    <img src='captcha/captcha.php' id='captcha-image'>
 
    <a href="javascript:void(0);" onclick="document.getElementById('captcha-image').src = 'captcha.php';">
        Обновить капчу
    </a>
</p>
       enter captcha: <input type="captcha" value="<?php echo $captcha; ?>" name="captcha"><br><br>
-->

 	 	<input type="submit" value="Login" name="submit-login"><br><br>
 	 </form>
 	 
 </body>
 </html>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question