私は基本的なログインシステムに取り組んでいます。私は多くのソースを使用しており、コードの多くの場所はオンラインの他のログイン システムからの抜粋です。問題は、ユーザー名とパスワードを入力しloginpage.html
、このファイル BLANK PAGE にリダイレクトするときに、完全に空白のページを単純かつ適切に取得していることです。
<?php
error_reporting(E_ALL ^ E_NOTICE);
include 'connectingshit.php';
//Basically naming a session and starting one
session_name('litLogin');
//The cookie is going to live for 2 weeks
session_set_cookie_params(2*7*24*60*60);
//Now we actually start the session
session_start();
ob_start();
if($_SESSION['id'] && !isset($_COOKIE['RemainLoggedIn']) && !$_SESSION['rememberMe'])
{
// If you are logged in, but you don't have the cookie (browser restarts)
// and you have not checked the rememberMe checkbox:
$_SESSION = array();
session_destroy();
// Destroy the session
}
if(isset($_POST['submit']))
{
//I hope I know what I am doing, this is supposed to hold our errors.
$errors = array();
if(!$_POST['username'] || !$_POST['password'])
$errors[] = 'All the fields must be filled in buddyboy!';
if(!count($errors))
{
//Assigning the input form shit to the variables/strings or wtf they are
$tinkerbells_username = $_POST['username'];
$tinkerbells_password = $_POST['password'];
$_POST['rememberMe'] = (int)$_POST['rememberMe'];
// We remove all dangerous characters (!!!!) WTF? Escaping them "WOW"...
$tinkerbells_username = stripslashes($tinkerbells_username);
$tinkerbells_password = stripslashes($tinkerbells_password);
$tinkerbells_username = mysqli_real_escape_string($conn, $tinkerbells_username);
$tinkerbells_password = mysqli_real_escape_string($conn, $tinkerbells_password);
$row = mysqli_fetch_assoc('SELECT id, username, password FROM members WHERE username = "$niloquieroser_username" AND password = "$niloquieroser_password"');
//Does basically the username exist when $row lookes for it in the database
if(($row['username']) && ($niloquieroser_username == $tinkerbells_username && $niloquieroser_password == $tinkerbells_password))
{
//Now fortunately or unfortunatley if it did work and everything is fine
//We can continue.....
$_SESSION['username'] = $row['username'];
$_SESSION['id'] = $row['id'];
$_SESSION['rememberMe'] = $_POST['rememberMe'];
//We store some data in the session
setcookie('RemainLoggedIn',$_POST['rememberMe']);
//cookie gets created
}
else $errors[]=("Wrongs username or/and password!");
}
header("Location: success.html");
exit;
}
ob_end_flush();
?>