Advertisement
Guest User

login.php

a guest
Jun 18th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.42 KB | None | 0 0
  1. <?php include("includes/header.php"); ?>
  2. <?php
  3.  
  4.  
  5. $CONNECT = mysqli_connect('localhost', 'litcoine_Trollbump', '4994797712alex', 'litcoine_project');
  6.   if (!$CONNECT) {
  7.     die('Ошибка соединения: ' . mysql_error());
  8.   }
  9.   //echo("Успешно соединились");
  10.  
  11. if($_COOKIE['enter'] != "")
  12. {
  13.     header("Location: intropage.php");
  14. }
  15.  
  16.  
  17. //echo("1");
  18. if (isset($_POST['login']))
  19. {
  20.     //echo("2");
  21.     if(!empty($_POST['username']) && !empty($_POST['password']))
  22.     {
  23.         $username=$_POST['username'];
  24.         $password=md5(md5(md5(md5(md5($_POST['password'])))));
  25.        
  26.         $result_set = $CONNECT->query("SELECT * FROM users WHERE login='$username' AND password='$password'");
  27.         $row = $result_set->fetch_assoc();
  28.        
  29.         if($row)
  30.         {
  31.        
  32.         $dbusername=$row['login'];
  33.         $dbpassword=$row['password'];
  34.         $type = $row['type'];
  35.    
  36.         if($username == $dbusername && $password == $dbpassword)
  37.         {
  38.        
  39.         if(setcookie('enter', $username, time() + 3600, "/", "litcoiners.xyz"))
  40.         {
  41.             //echo("cookie set");
  42.  
  43.         }
  44.         if(setcookie('type', $type, time() + 3600, "/", "litcoiners.xyz"))
  45.         {
  46.             //echo("cookie set");
  47.  
  48.         }
  49.         /* Redirect browser */
  50.         header("Location: intropage.php");
  51.         }
  52.        
  53.         }
  54.         else
  55.         {
  56.             $message =  "Invalid username or password!";
  57.         }
  58.     }
  59.     else
  60.     {
  61.         $message = "All fields are required!";
  62.     }
  63.  
  64. }
  65. ?>
  66.  
  67.  
  68.  
  69.  
  70.     <div class="container mlogin">
  71.             <div id="login">
  72.     <h1>LOGIN</h1>
  73. <form name="loginform" id="loginform" action="" method="POST">
  74.     <p>
  75.         <label for="user_login">Username<br />
  76.         <input type="text" name="username" id="username" class="input" value="" size="20" /></label>
  77.     </p>
  78.     <p>
  79.         <label for="user_pass">Password<br />
  80.         <input type="password" name="password" id="password" class="input" value="" size="20" /></label>
  81.     </p>
  82.         <p class="submit">
  83.         <input type="submit" name="login" class="button" value="Log In" />
  84.     </p>
  85.         <p class="regtext">No account yet? <a href="register.php" >Register Here</a>!</p>
  86. </form>
  87.  
  88.     </div>
  89.  
  90.     </div>
  91.    
  92.     <?php include("includes/footer.php"); ?>
  93.    
  94.     <?php if (!empty($message)) {echo "<p class=\"error\">" . "MESSAGE: ". $message . "</p>";} ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement