Fix
This commit is contained in:
parent
7573cb1d4b
commit
d42a6dd034
@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
ini_set('display_errors', true);
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
|
|
||||||
function connect()
|
function connect()
|
||||||
@ -6,4 +9,11 @@
|
|||||||
return mysqli_connect(MYSQL_HOST, MYSQL_USERNAME, MYSQL_PASSWORD, MYSQL_DATABASE);
|
return mysqli_connect(MYSQL_HOST, MYSQL_USERNAME, MYSQL_PASSWORD, MYSQL_DATABASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function text($text = '')
|
||||||
|
{
|
||||||
|
header('Content-Type: text/plain');
|
||||||
|
echo $text;
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
session_start();
|
session_start();
|
@ -2,4 +2,4 @@
|
|||||||
define('MYSQL_HOST', 'localhost');
|
define('MYSQL_HOST', 'localhost');
|
||||||
define('MYSQL_USERNAME', 'secure');
|
define('MYSQL_USERNAME', 'secure');
|
||||||
define('MYSQL_PASSWORD', 'password');
|
define('MYSQL_PASSWORD', 'password');
|
||||||
define('MYSQL_DATABASE', 'securedb');
|
define('MYSQL_DATABASE', 'verysecure');
|
@ -1,3 +1,8 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<link href="https://stackpath.bootstrapcdn.com/bootswatch/4.3.1/lux/bootstrap.min.css" rel="stylesheet" integrity="sha384-hVpXlpdRmJ+uXGwD5W6HZMnR9ENcKVRn855pPbuI/mwPIEKAuKgTKgGksVGmlAvt" crossorigin="anonymous">
|
<link href="https://stackpath.bootstrapcdn.com/bootswatch/4.3.1/lux/bootstrap.min.css" rel="stylesheet" integrity="sha384-hVpXlpdRmJ+uXGwD5W6HZMnR9ENcKVRn855pPbuI/mwPIEKAuKgTKgGksVGmlAvt" crossorigin="anonymous">
|
||||||
<title>Insecure PHP Application for SQL Injection Testing</title>
|
<title>Insecure PHP Application for SQL Injection Testing</title>
|
||||||
|
<style type="text/css">
|
||||||
|
body {
|
||||||
|
margin-top: 70px;
|
||||||
|
}
|
||||||
|
</style>
|
18
login.php
18
login.php
@ -6,19 +6,27 @@
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($_POST['username'], $_POST['password'])) {
|
if (!isset($_REQUEST['username'], $_REQUEST['password'])) {
|
||||||
header('Location: ./');
|
header('Location: ./');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$username = $_POST['username'];
|
$username = $_REQUEST['username'];
|
||||||
$password = $_POST['password'];
|
$password = $_REQUEST['password'];
|
||||||
|
|
||||||
$con = connect();
|
$con = connect();
|
||||||
$getUser = mysqli_query($con, "SELECT * FROM users WHERE username='$username' AND password='$password';");
|
$sql = "SELECT * FROM users WHERE username='$username' AND password='$password';";
|
||||||
|
|
||||||
|
$getUser = mysqli_query($con, $sql);
|
||||||
|
|
||||||
|
if (!$getUser) {
|
||||||
|
header('Location: ./');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
$user = mysqli_fetch_assoc($getUser);
|
$user = mysqli_fetch_assoc($getUser);
|
||||||
|
|
||||||
$_SESSION['id'] = $user['id'];
|
$_SESSION['id'] = $user['id'];
|
||||||
header('Location: ./user.php');
|
header('Location: ./');
|
||||||
exit;
|
exit;
|
||||||
?>
|
?>
|
7
logout.php
Normal file
7
logout.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
require 'includes/common.php';
|
||||||
|
|
||||||
|
session_destroy();
|
||||||
|
|
||||||
|
header('Location: ./');
|
||||||
|
exit;
|
Loading…
Reference in New Issue
Block a user