Skip to content

Commit bfba26b

Browse files
committed
Fixed some bugs and SQL injection.
1 parent 45d5889 commit bfba26b

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

_login.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ function redirect() {
2424
require ('_database.php');
2525
$user = $_POST['user'];
2626
$pass = $_POST['pass'];
27-
// <-- Bad.
2827

29-
$query = "SELECT user_name, class, person_id FROM users WHERE user_name = '$user' AND password = '$pass'";
28+
$query = "SELECT user_name, class, person_id FROM users WHERE user_name = :username AND password = :password";
3029

3130
$statement = oci_parse($connection, $query);
31+
oci_bind_by_name($statement, ':username', $user);
32+
oci_bind_by_name($statement, ':password', $pass);
3233
$results = oci_execute($statement);
3334

3435
// Did we get a valid result?

setup.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ DROP TABLE users;
1111
DROP TABLE persons;
1212
DROP SEQUENCE record_id_seq;
1313
DROP SEQUENCE image_id_seq;
14+
DROP SEQUENCE person_id_seq;
1415

1516
/*
1617
* To store the personal information

users.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</p>
1313
<div>
1414
<form id="searchform" required="1" name="search_users" method="get" action="<?php $PHP_SELF ?>" >
15-
<input type="text" name="q" />
15+
<input type="text" name="q" value="<?php echo $_GET['q']; ?>" />
1616
<input type="submit" value="Search" />
1717
</form>
1818
</div>

0 commit comments

Comments
 (0)