-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudentRepo.php
More file actions
33 lines (31 loc) · 1015 Bytes
/
studentRepo.php
File metadata and controls
33 lines (31 loc) · 1015 Bytes
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
<?php
include_once 'DB_Connection.php';
include_once 'sqlFunctions.php';
class StudentRepo{
private $connection;
function __construct()
{
$conn = new dbConnect();
$this->connection = $conn->connectDB();
}
function login(){
$conn = $this->connection;
$name = $_POST['name'];
$password = $_POST['password'];
$sql = "SELECT * FROM students WHERE username='$name'";
$statement = $conn->query($sql);
$student = $statement->fetch(PDO::FETCH_ASSOC);
if($statement->rowCount() < 1){
echo"<script>alert('Incorrect Username');</script>";
}else{
if(!password_verify($password,$student['password'])){
echo"<script>alert('Incorrect Password');</script>";
}else{
session_start();
$_SESSION['username'] = $student['username'];
header("location:courses.php");
}
}
}
}
?>