Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- require_once("DB.php");
- if ($_SESSION['logined'] !== null) {
- $u = $_SESSION['logined'];
- header("Location: home.php",true,303);
- }
- if (isset($_POST['username']) && isset($_POST['pass']))
- {
- $username=$_POST['username']=trim($_POST['username']);
- $pass=$_POST['pass']=trim($_POST['pass']);
- $DB = DB::con();
- $sql = $DB->prepare("select * from students where login = ? and password = ?");
- $sql->execute(array($username, md5($pass)));
- $sql->setFetchmode(PDO::FETCH_ASSOC);
- foreach ($sql as $row)
- {
- if ($username==$row['login'])
- {
- $_SESSION['logined']=$username;
- header("Location: p_home.php");
- }
- else
- {die('Такой логин с паролем не найдены в базе данных.');
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement