-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetClasses.php
More file actions
40 lines (38 loc) · 1.2 KB
/
getClasses.php
File metadata and controls
40 lines (38 loc) · 1.2 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
<?php
session_start();
if(isset($_POST["username"]))
{
$username = $_POST["username"];
echo "username: " . $username;
}
$password='';
if(isset($_POST["password"]))
{
$password = $_POST["password"];
}
$servername = "localhost";
$dbusername = "root";
$dbpassword = "";
$dbname = "webapps";
//create connection with database
$conn = new mysqli($servername, $dbusername, $dbpassword, $dbname);
//confirming that connection was made
if($conn->connect_error)
{
die("God Damn connection failed: ". $conn->connect_error);
}
//sql to check if username and pw are correc
$sql = "SELECT `class1`,`class2`,`class3` FROM `users` WHERE `username`='" . $username . "'";
//echo $sql;
$result = $conn->query($sql);
//echo $result->num_rows . " is num rows in the result";
$arr = mysqli_fetch_assoc($result);
echo '{"class1":"' . $arr['class1'] . '", "class2":"' . $arr['class2'] . '", "class3":"' . $arr['class3'] . '"}';
//$_SESSION["error"] = "Sorry this username is not on file. Please try again";
//header("Location: login.php");
//echo "should have redirected and not reached this line <br>";
//exit();
//echo $_SESSION["username"]."<br>";
//echo $_SESSION["password"]."<br>";
//fclose($usersfile);
?>