-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandleForm.php
More file actions
52 lines (42 loc) · 1.48 KB
/
handleForm.php
File metadata and controls
52 lines (42 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
// Handle POST form with DV_User table from datamining database
include "dbconfig.php";
$password=$_POST['password'];
$username=$_POST['username'];
// Connect or die
$con = mysqli_connect($dbhostname, $dbusername, $dbpassword, $dbname);
if(!$con) {
// $protocol = (isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0');
// $code = 500;
// $text = mysqli_connect_error();
// header($protocol . ' ' . $code . ' ' . $text);
http_response_code(500);
exit;
}
$sql = "SELECT * FROM datamining.DV_User WHERE login='$username' AND password='$password' LIMIT 1";
$result = mysqli_query($con, $sql);
$num = mysqli_num_rows($result);
// if ($num == 0) {
// $protocol = (isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0');
// $code = 500;
// $text = "No user with that login."
// header($protocol . ' ' . $code . ' ' . $text);
// mysqli_close($con);
// exit;
// } else {
$row = mysqli_fetch_array($result);
if ($row['password'] == $password) {
echo "SUCCESS";
http_response_code(200);
} else {
// header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);
http_response_code(500);
}
// mysqli_close($con);
// $protocol = (isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0');
// $code = 500;
// $text = "Correct user wrong password."
// header($protocol . ' ' . $code . ' ' . $text);
// }
exit;
?>