how can I add the students and he can login using php and mysql [closed] - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Friday, September 22, 2023

how can I add the students and he can login using php and mysql [closed]

I created a teacher's evaluation system and only the admin can add students and faculties. When the students are added, he can login and evaluate the teacher. I can add students to my database but when the students press the login button he can't login. The Index.php is the link of my admin panel. I'm just new to php mysql.

<?php
include 'config.php';
//if user click login button
if(isset($_POST['login'])) {
$email = mysqli_real_escape_string($con, $_POST['email']);
$password = mysqli_real_escape_string($con, $_POST['password']);
$check_email = "SELECT * FROM usertable WHERE email = '$email'";
$res = mysqli_query($con, $check_email);
if(mysqli_num_rows($res) > 0) {
$fetch = mysqli_fetch_assoc($res);
$fetch_pass = $fetch['password'];
if(password_verify($password, $fetch_pass)) {
$_SESSION['email'] = $email;
$_SESSION['password'] = $password;
header('location: index.php');
} else {
$errors['email'] = "Incorrect email or password!";
}
} else {
$errors['email'] = "It's look like you're not yet a member!<br>Create account first to log in";
}
}
?>

/add students

<?php
@include 'config.php';
if (isset($_POST['save'])) {
$school_id = $_POST['school-id'];
$email = $_POST['email'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$class = $_POST['class_id'];
$password = $_POST['password'];
$add = "INSERT INTO `student_list`(`school_id`, `email`, `firstname`, `lastname`, `class`, `password`, `role`) VALUES ('$school_id', '$email', '$firstname', '$lastname', '$class', '$password',
'Student')";
$rsl = mysqli_query($con, $add);
echo "<script>alert('Data successfully stored')</script>";
if (!$rsl) {
die(mysqli_error($con));
}
}
if (isset($_POST['cancel'])){
header("Location: manage_class.php");
}
?>

I did was to add the students in my database but when the students click the login button he can't login. I want when the students click the login button it will redirect to other page not in the index.php because it's my admin panel link



source https://stackoverflow.com/questions/77152364/how-can-i-add-the-students-and-he-can-login-using-php-and-mysql

No comments:

Post a Comment