PHP code
<?php
ob_start();
session_start();
include "sql_and_php_debug_with_anticheat.php";
mysql_connect("localhost", "login2", "login2");
mysql_select_db("login2");
?>
<h1>Login by hand (e.g. under 'admin' : 'admin')</h1>
Flag is in `flag`.flag, it is a 7-digit number.<br/>
(you can check if SQL query returned TRUE or FALSE (login OK or NOT ok). Can you get data from DB using that?)<br/><br/>
<?php
if (isset($_SESSION['loggedIn'])) {
if (isset($_GET['logout'])) {
unset($_SESSION['loggedIn']);
ob_end_clean();
header("Location: ?", true, 302);
exit;
}
echo "Welcome, user! The page is under construction<p/><a href='?logout&sig_logout'>Log out »</a>";
} else {
if (isset($_POST['login'])) {
$login = $_POST['login'];
$password = $_POST['password'];
$res = mysql_query("SELECT * FROM users WHERE login = '$login' AND password = '$password'");
if (mysql_num_rows($res) > 0) {
$_SESSION['loggedIn'] = true;
ob_end_clean();
header("Location: ?", true, 302);
exit;
} else {
echo "Bad username or password! Hope this does not give you information you need ;)";
}
}
?>
<form method="POST" id="form">Login: <input type="text" name="login" id="login" /><br/>
Password: <input type="password" name="password" id="password" /><br/>
<input type="submit" value="Login »" />
<input type="hidden" name="sig_login" id="sig_login" />
<input type="hidden" name="sig_password" id="sig_password" />
</form>
<?php
}