0% found this document useful (0 votes)
0 views50 pages

Addmin

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views50 pages

Addmin

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 50

Addmin

api_mentor.php
<?php
session_start();
if (isset($_SESSION['logged']) && $_SESSION['logged'] == true && $_SESSION['role']
== 'Admin') {
require('../../includes/conn.php');
} else {
header('location: ../../index.php');
}
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;

require '../PHPMailer/src/Exception.php';
require '../PHPMailer/src/PHPMailer.php';
require '../PHPMailer/src/SMTP.php';

if (isset($_POST['email'])) {
$name = mysqli_escape_string($conn, $_POST['name']);
$email = mysqli_escape_string($conn, $_POST['email']);
$password = mysqli_escape_string($conn, $_POST['password']);
$dob = mysqli_escape_string($conn, $_POST['dob']);
$department = mysqli_escape_string($conn, $_POST['department']);
$mobile = mysqli_escape_string($conn, $_POST['mobile']);
$gender = mysqli_escape_string($conn, $_POST['gender']);

// Check if email already exists


$checkEmailSql = "SELECT * FROM users WHERE email = '$email'";
$checkEmailResult = mysqli_query($conn, $checkEmailSql);

if (mysqli_num_rows($checkEmailResult) > 0) {
session_start();
$_SESSION['msg'] = '<script>Toastify({
text: "Email already exists",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "red",
}).showToast()</script>';
header("location:../mentor.php");
exit;
}

$hashedPassword = password_hash($password, PASSWORD_DEFAULT);

if (isset($_FILES['image']) && $_FILES['image']['error'] === UPLOAD_ERR_OK) {


$imageTmpName = $_FILES['image']['tmp_name'];
$imagePath = time() . ".png";
move_uploaded_file($imageTmpName, "../../images/mentor/" . $imagePath);
}

mysqli_begin_transaction($conn);

$addUserSql = "INSERT INTO users (`email`, `password`, `role`) VALUES


('$email', '$hashedPassword', 'Mentor')";
$addUserResult = mysqli_query($conn, $addUserSql);
$user_id = mysqli_insert_id($conn);

$addMentorSql = "INSERT INTO mentor (`user_id`, `name`, `mobile`, `email`,


`gender`, `dob`, `department`, `photo`)
VALUES ('$user_id', '$name', '$mobile', '$email', '$gender', '$dob',
'$department', '$imagePath')";

$addMentorResult = mysqli_query($conn, $addMentorSql);

if ($addMentorResult && $addUserResult) {


// Send email
$mail = new PHPMailer(true);

try {
$mail->isSMTP();

$mail->Host = 'mail.projectstore.vip';

$mail->SMTPAuth = true;
$mail->Port = 587;
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also
accepted
$mail->SMTPDebug = 2;
$mail->Username = '[email protected]';
$mail->Password = '12345678';
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);

$mail->setFrom('[email protected]', 'Student Mentoring System');


$mail->addAddress($email, $name);

// Add a subject
$mail->Subject = 'Account Information';

$mail->Body =
" Hello $name,
Welcome to the Student Mentoring System! Your account has been
successfully created. Here are your login details:
- Username: $email
- Password: $password
Keep your login credentials secure. If you have any questions or
encounter issues,
please contact our support team at [Student Mentoring System].";

$mail->send();

mysqli_commit($conn);

session_start();
$_SESSION['msg'] = '<script>Toastify({
text: "Mentor added and email sent successfully",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "#4fbe87",
}).showToast()</script>';

header("location:../mentor.php");
} catch (Exception $e) {
mysqli_rollback($conn);

session_start();
$_SESSION['msg'] = '<script>Toastify({
text: "Error sending welcome email. Mentor not added.",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "red",
}).showToast()</script>';

header("location:../mentor.php");
}
} else {
mysqli_rollback($conn);

session_start();
$_SESSION['msg'] = '<script>Toastify({
text: "Something Went Wrong. Mentor not added.",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "red",
}).showToast()</script>';

header("location:../mentor.php");
}
}

if (isset($_POST['updateemail'])) {
$updateid = mysqli_escape_string($conn, $_POST['updateid']);
$updateemail = mysqli_escape_string($conn, $_POST['updateemail']);
$updatename = mysqli_escape_string($conn, $_POST['updatename']);
$updatedob = mysqli_escape_string($conn, $_POST['updatedob']);
$updatedepartment = mysqli_escape_string($conn, $_POST['updatedepartment']);
$updatemobile = mysqli_escape_string($conn, $_POST['updatemobile']);
$updategender = mysqli_escape_string($conn, $_POST['updategender']);
$updatepassword = mysqli_escape_string($conn, $_POST['updatepassword']);
// Check if a new image is uploaded
if (isset($_FILES['updateimage']) && $_FILES['updateimage']['error'] ===
UPLOAD_ERR_OK) {
// Delete the old image file
// No new image uploaded, keep the existing image path
$selectStudentSql = "SELECT * FROM mentor WHERE mentor_id = $updateid";
$selectStudentResult = mysqli_query($conn, $selectStudentSql);
$row = mysqli_fetch_assoc($selectStudentResult);
$updateimagePath = $row['photo']; // Assuming $row['photo'] contains the
current image path
if (!empty($updateimagePath)) {
$oldImagePath = "../../images/mentor/" . $updateimagePath;
if (file_exists($oldImagePath)) {
unlink($oldImagePath);
}
}

// Upload the new image


$updateimageTmpName = $_FILES['updateimage']['tmp_name'];
$updateimagePath = time() . ".png";
move_uploaded_file($updateimageTmpName, "../../images/mentor/" .
$updateimagePath);
} else {
// No new image uploaded, keep the existing image path
$selectStudentSql = "SELECT * FROM mentor WHERE mentor_id = $updateid";
$selectStudentResult = mysqli_query($conn, $selectStudentSql);
$row = mysqli_fetch_assoc($selectStudentResult);
$updateimagePath = $row['photo']; // Assuming $row['photo'] contains the
current image path
}

if (!empty($updatepassword)) {
$updatehashedPassword = password_hash($updatepassword, PASSWORD_DEFAULT);
$updateUserSql = "UPDATE users SET `password` = '$updatehashedPassword'
WHERE `email` = '$updateemail'";
$updateUserResult = mysqli_query($conn, $updateUserSql);
$mail = new PHPMailer(true);

try {
$mail->isSMTP();

$mail->Host = 'mail.projectstore.vip';

$mail->SMTPAuth = true;
$mail->Port = 587;
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also
accepted
$mail->SMTPDebug = 2;
$mail->Username = '[email protected]';
$mail->Password = '12345678';
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);

$mail->setFrom('[email protected]', 'Student Mentoring System');


$mail->addAddress($updateemail, $updatename);

// Add a subject
$mail->Subject = 'Update Account Information';

$mail->Body =
" Hello $name,
Welcome to the Student Mentoring System! Your old password changed
successfully. Here are your new login details:
- Username: $updateemail
- Password: $updatepassword
Keep your login credentials secure. If you have any questions or
encounter issues,
please contact our support team at [Student Mentoring System].";

$mail->send();

} catch (Exception $e) {


echo "errrrrrrrrrrr";

}
} else {
// No new password provided, don't update it
$updateUserResult = true;
}

// Update other fields in the student table


$updateStudentSql = "UPDATE mentor SET
`name` = '$updatename',
`email` = '$updateemail',
`dob` = '$updatedob',
`department` = '$updatedepartment',
`mobile` = '$updatemobile',
`gender` = '$updategender',
`photo` = '$updateimagePath'
WHERE `mentor_id` = $updateid";

$updateStudentResult = mysqli_query($conn, $updateStudentSql);

if ($updateStudentResult && $updateUserResult) {

// Profile updated successfully


$_SESSION['msg'] = '<script>Toastify({
text: "Profile Updated Successfully.",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "#4fbe87",
}).showToast()</script>';
header("location: ../mentor.php");
} else {
// Error updating profile
$_SESSION['msg'] = '<script>Toastify({
text: "Something Went Wrong.",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "red",
}).showToast()</script>';
header("location: ../mentor.php");
}
} else {
echo "errrrrrrrrrrr";
}

if (isset($_GET['del'])) {
$del = mysqli_real_escape_string($conn, $_GET['del']);

$getMentorDataSql = "SELECT user_id, photo FROM mentor WHERE mentor_id = $del";


$mentorDataResult = mysqli_query($conn, $getMentorDataSql);

if ($mentorDataResult) {
if (mysqli_num_rows($mentorDataResult) > 0) {
$mentorData = mysqli_fetch_assoc($mentorDataResult);
$userID = $mentorData['user_id'];
$photoFilename = $mentorData['photo'];

// Delete the image file


if (!empty($photoFilename) && file_exists("../../images/mentor/" .
$photoFilename)) {
unlink("../../images/mentor/" . $photoFilename);
}

$deleteMentorSql = "DELETE FROM mentor WHERE mentor_id = $del";


$deleteUserSql = "DELETE FROM users WHERE id = $userID";

$deleteMentorResult = mysqli_query($conn, $deleteMentorSql);


$deleteUserResult = mysqli_query($conn, $deleteUserSql);

if ($deleteMentorResult && $deleteUserResult) {


session_start();
$_SESSION['msg'] = '<script>Toastify({
text: "Mentor and associated User Deleted Successfully.",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "#4fbe87",
}).showToast()</script>';
header("location:../mentor.php");
} else {
session_start();
$_SESSION['msg'] = '<script>Toastify({
text: "Something went wrong in the deletion process!",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "red",
}).showToast()</script>';
header("location:../mentor.php");
}
} else {
session_start();
$_SESSION['msg'] = '<script>Toastify({
text: "Mentor not found.",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "red",
}).showToast()</script>';
header("location:../mentor.php");
}
} else {
session_start();
$_SESSION['msg'] = '<script>Toastify({
text: "Something Went Wrong.",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "red",
}).showToast()</script>';
header("location:../mentor.php");
}
}

api_notification.php

<?php
session_start();
require "../../includes/conn.php";
if(isset($_SESSION['logged']) && $_SESSION['logged'] == true && $_SESSION['role']
== "Admin"){
}else{
echo "
<script>
window.location.href = '../../index.php';
</script>
";
exit;
}
if (isset($_POST['stud'])) {
$message = mysqli_escape_string($conn, $_POST['message']);
$title = mysqli_escape_string($conn, $_POST['title']);
$mentorId = 1;
$to = $_POST['stud'];
// Replace with your registration tokens and message data
$registrationTokens = [];

foreach ($to as $key => $value) {


$registrationTokens[] = $value;
}

// Send FCM notifications


$resss = sendFirebaseNotification($registrationTokens, $title, $message);

if($resss->success == 1){
session_start();
$_SESSION['msg'] = '<script>
Toastify({
text: "Notifiction Send Successfully",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "#0B8803",
}).showToast()

</script>';

header('location: ../notification.php');
exit;
}else{
session_start();
$_SESSION['msg'] = '<script>
Toastify({
text: "Something Went Wrong.",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "#F7360D",
}).showToast()

</script>';

header('location: ../notification.php');
exit;
}

// sendFCMNotification($registrationTokens, $messageData);
} else if (isset($_GET['type']) && $_GET['type'] == "token") {
$token = $_GET['token'];
$studentid = $_GET['studentid'];
// $sql = "UPDATE `student` SET `fcm_device_token`='$token' WHERE
`student_id`=1";
$sql = "UPDATE student
SET fcm_device_token = '$token'
WHERE `student_id`=$studentid";
$res = mysqli_query($conn, $sql);
}

function sendFCMNotification($registrationTokens, $messageData)


{
// Replace with your FCM Server Key
$serverKey =
'AAAAtkchXMI:APA91bETkhKLNU46nOTgk2axCdGseaiVTSXKbjx7WydjIugJBE3RVl9Rmmn2c1SwmAgl6e
6NyAaXot5LbWDzm8qMKpQd2Ubzkm4SFZYPJpLO_zr209Z4Ulyvy8qKj1XGMNqqlZapSi82';

// FCM endpoint
$url = 'https://fcm.googleapis.com/fcm/send';

// Build the notification payload


$payload = [
'message' => [
'registration_ids' => $registrationTokens, // or 'topic' => 'your-
topic-name' for sending to a topic
'notification' => [
'title' => $messageData['title'],
'body' => $messageData['body'],
],
],
];

$headers = [
'Authorization: key= ' . $serverKey,
'Content-Type: application/json',
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));

$result = curl_exec($ch);
echo $result;
// if (curl_errno($ch)) {
// echo 'FCM request failed: ' . curl_error($ch) . PHP_EOL;
// } else {
// $response = json_decode($result, true);
// // Check the response for errors if needed
// // $response contains the FCM server response
// echo 'FCM notification sent successfully to ' . PHP_EOL;
// }

curl_close($ch);
}

function sendFirebaseNotification($fb_key_array, $title, $message)


{
$authorization_key =
"AAAAtkchXMI:APA91bETkhKLNU46nOTgk2axCdGseaiVTSXKbjx7WydjIugJBE3RVl9Rmmn2c1SwmAgl6e
6NyAaXot5LbWDzm8qMKpQd2Ubzkm4SFZYPJpLO_zr209Z4Ulyvy8qKj1XGMNqqlZapSi82";

$finalPostArray = array(
'registration_ids' => $fb_key_array,
'notification' => array(
'body' => $message,
'title' => $title
)
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://fcm.googleapis.com/fcm/send");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($finalPostArray)); //Post
Fields
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json',
'Authorization: key=' . $authorization_key));
$server_output = curl_exec($ch);
curl_close($ch);
return json_decode($server_output);
}

Api_Student.php
<?php
session_start();
if (isset($_SESSION['logged']) && $_SESSION['logged'] == true && $_SESSION['role']
== 'Admin') {
require('../../includes/conn.php');
} else {
header('location: ../../index.php');
}
use \PHPMailer\PHPMailer\PHPMailer;
use \PHPMailer\PHPMailer\SMTP;
use \PHPMailer\PHPMailer\Exception;

require '../PHPMailer/src/Exception.php';
require '../PHPMailer/src/PHPMailer.php';
require '../PHPMailer/src/SMTP.php';

if (isset($_POST['email'])) {
$name = mysqli_escape_string($conn, $_POST['name']);
$email = mysqli_escape_string($conn, $_POST['email']);
$password = mysqli_escape_string($conn, $_POST['password']);
$dob = mysqli_escape_string($conn, $_POST['dob']);
$department = mysqli_escape_string($conn, $_POST['department']);
$mobile = mysqli_escape_string($conn, $_POST['mobile']);
$gender = mysqli_escape_string($conn, $_POST['gender']);

// Check if email already exists


$checkEmailSql = "SELECT * FROM users WHERE email = '$email'";
$checkEmailResult = mysqli_query($conn, $checkEmailSql);

if (mysqli_num_rows($checkEmailResult) > 0) {

session_start();
$_SESSION['msg'] = '<script>Toastify({
text: "Email already exists",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "red",
}).showToast()</script>';
header("location:../student.php");
exit;
}
// Generate a random password
$hashedPassword = password_hash($password, PASSWORD_DEFAULT);

// echo $gender;
if (isset($_FILES['image']) && $_FILES['image']['error'] === UPLOAD_ERR_OK) {
$imageTmpName = $_FILES['image']['tmp_name'];
$imagePath = time() . ".png";
move_uploaded_file($imageTmpName, "../../images/" . $imagePath);
}

mysqli_begin_transaction($conn);

$addUserSql = "INSERT INTO users (`email`, `password`, `role`) VALUES


('$email', '$hashedPassword', 'Student')";
$addUserResult = mysqli_query($conn, $addUserSql);

$user_id = mysqli_insert_id($conn);

$addStudentSql = "INSERT INTO student (`user_id`, `name`, `mobile`, `email`,


`gender`, `dob`, `department`, `photo`)
VALUES ('$user_id', '$name', '$mobile', '$email', '$gender', '$dob',
'$department', '$imagePath')";

$addStudentResult = mysqli_query($conn, $addStudentSql);

if ($addStudentResult && $addUserResult) {


mysqli_commit($conn);

$mail = new PHPMailer(true);

try {
$mail->isSMTP();

$mail->Host = 'mail.projectstore.vip';

$mail->SMTPAuth = true;
$mail->Port = 587;
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also
accepted
// $mail->SMTPDebug = 2;
$mail->Username = '[email protected]';
$mail->Password = '12345678';
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);

$mail->setFrom('[email protected]', 'Student Mentoring System');


$mail->addAddress($email, $name);

// Add a subject
$mail->Subject = 'Account Information';

$mail->Body =
" Hello $name,
Welcome to the Student Mentoring System! Your account has been
successfully created. Here are your login details:
- Username: $email
- Password: $password
Keep your login credentials secure. If you have any questions or
encounter issues,
please contact our support team at [Student Mentoring System].";

$mail->send();

session_start();
$_SESSION['msg'] = '<script>Toastify({
text: "Student and Email sent successfully...",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "#4fbe87",
}).showToast()</script>';
header("location:../student.php");
} catch (Exception $e) {
session_start();
$_SESSION['msg'] = '<script>Toastify({
text: "Error: .' . $mail->ErrorInfo . '",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "red",
}).showToast()</script>';
header("location:../student.php");
}
} else {
mysqli_rollback($conn);

session_start();
$_SESSION['msg'] = '<script>Toastify({
text: "Error inserting data: ' . mysqli_error($conn);
'",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "red",
}).showToast()</script>';
header("location:../student.php");
echo 'Error inserting data: ' . mysqli_error($conn);
}
}
// print_r($_FILES);

if (isset($_POST['updateemail'])) {
$updateid = mysqli_escape_string($conn, $_POST['updateid']);
$updateemail = mysqli_escape_string($conn, $_POST['updateemail']);
$updatename = mysqli_escape_string($conn, $_POST['updatename']);
$updatedob = mysqli_escape_string($conn, $_POST['updatedob']);
$updatedepartment = mysqli_escape_string($conn, $_POST['updatedepartment']);
$updatemobile = mysqli_escape_string($conn, $_POST['updatemobile']);
$updategender = mysqli_escape_string($conn, $_POST['updategender']);
$updatepassword = mysqli_escape_string($conn, $_POST['updatepassword']);

// Check if a new image is uploaded


if (isset($_FILES['updateimage']) && $_FILES['updateimage']['error'] ===
UPLOAD_ERR_OK) {
// Delete the old image file
// No new image uploaded, keep the existing image path
$selectStudentSql = "SELECT * FROM student WHERE student_id = $updateid";
$selectStudentResult = mysqli_query($conn, $selectStudentSql);
$row = mysqli_fetch_assoc($selectStudentResult);
$updateimagePath = $row['photo']; // Assuming $row['photo'] contains the
current image path
if (!empty($updateimagePath)) {
$oldImagePath = "../../images/" . $updateimagePath;
if (file_exists($oldImagePath)) {
unlink($oldImagePath);
}
}

// Upload the new image


$updateimageTmpName = $_FILES['updateimage']['tmp_name'];
$updateimagePath = time() . ".png";
move_uploaded_file($updateimageTmpName, "../../images/" .
$updateimagePath);
} else {
// No new image uploaded, keep the existing image path
$selectStudentSql = "SELECT * FROM student WHERE student_id = $updateid";
$selectStudentResult = mysqli_query($conn, $selectStudentSql);
$row = mysqli_fetch_assoc($selectStudentResult);
$updateimagePath = $row['photo']; // Assuming $row['photo'] contains the
current image path
}

// Check if a new password is provided


if (!empty($updatepassword)) {
$updatehashedPassword = password_hash($updatepassword, PASSWORD_DEFAULT);
$updateUserSql = "UPDATE users SET `password` = '$updatehashedPassword'
WHERE `email` = '$updateemail'";
$updateUserResult = mysqli_query($conn, $updateUserSql);
$mail = new PHPMailer(true);

try {
$mail->isSMTP();

$mail->Host = 'mail.projectstore.vip';

$mail->SMTPAuth = true;
$mail->Port = 587;
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also
accepted
// $mail->SMTPDebug = 2;
$mail->Username = '[email protected]';
$mail->Password = '12345678';
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);

$mail->setFrom('[email protected]', 'Student Mentoring System');


$mail->addAddress($updateemail, $name);

// Add a subject
$mail->Subject = 'Update Account Information';

$mail->Body =
" Hello $name,
Welcome to the Student Mentoring System! Your old password changed
successfully. Here are your new login details:
- Username: $updateemail
- Password: $updatepassword
Keep your login credentials secure. If you have any questions or
encounter issues,
please contact our support team at [Student Mentoring System].";

$mail->send();
} catch (Exception $e) {
}
} else {
// No new password provided, don't update it
$updateUserResult = true;
}

// Update other fields in the student table


$updateStudentSql = "UPDATE student SET
`name` = '$updatename',
`email` = '$updateemail',
`dob` = '$updatedob',
`department` = '$updatedepartment',
`mobile` = '$updatemobile',
`gender` = '$updategender',
`photo` = '$updateimagePath'
WHERE `student_id` = $updateid";

$updateStudentResult = mysqli_query($conn, $updateStudentSql);

if ($updateStudentResult && $updateUserResult) {


// Profile updated successfully
$_SESSION['msg'] = '<script>Toastify({
text: "Profile Updated Successfully.",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "#4fbe87",
}).showToast()</script>';
header("location: ../student.php");
} else {
// Error updating profile
$_SESSION['msg'] = '<script>Toastify({
text: "Something Went Wrong.",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "red",
}).showToast()</script>';
header("location: ../student.php");
}
} else {
echo "errrrrrrrrrrr";
}

if (isset($_GET['del'])) {
$del = mysqli_real_escape_string($conn, $_GET['del']);
// die($del);
$getUserDataSql = "SELECT user_id, photo FROM student WHERE student_id = $del";
$userDataResult = mysqli_query($conn, $getUserDataSql);

if ($userDataResult) {
if (mysqli_num_rows($userDataResult) > 0) {
$userData = mysqli_fetch_assoc($userDataResult);
$userID = $userData['user_id'];
$photoFilename = $userData['photo'];
// Delete the image file
if (!empty($photoFilename) && file_exists("../../images/" .
$photoFilename)) {
unlink("../../images/" . $photoFilename);
}

$deleteStudentSql = "DELETE FROM student WHERE student_id = $del";


$deleteUserSql = "DELETE FROM users WHERE id = $userID";

$deleteStudentResult = mysqli_query($conn, $deleteStudentSql);


$deleteUserResult = mysqli_query($conn, $deleteUserSql);

if ($deleteStudentResult && $deleteUserResult) {


session_start();
$_SESSION['msg'] = '<script>Toastify({
text: "Student and associated User Deleted Successfully.",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "#4fbe87",
}).showToast()</script>';
header("location:../student.php");
} else {
session_start();
$_SESSION['msg'] = '<script>Toastify({
text: "Something went wrong in the deletion process!",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "red",
}).showToast()</script>';
header("location:../student.php");
}
} else {
session_start();
$_SESSION['msg'] = '<script>Toastify({
text: "Student not found.",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "red",
}).showToast()</script>';
header("location:../student.php");
}
} else {
session_start();
$_SESSION['msg'] = '<script>Toastify({
text: "Something Went Wrong.",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "red",
}).showToast()</script>';
header("location:../student.php");
}
}

index.php
<?php
require "../includes/header.php";
require "../includes/conn.php";

if(isset($_SESSION['logged']) && $_SESSION['logged'] == true && $_SESSION['role']


== "Admin"){
}else{
echo "
<script>
window.location.href = '../index.php';
</script>
";
exit;
}
?>

<div class="page-heading">
<div class="page-title">
<div class="row">
<div class="col-12 col-md-6 order-md-1 order-last">
<h3>Student Mentoring System</h3>
<p class="text-subtitle text-muted">Dashboard</p>
</div>
<div class="col-12 col-md-6 order-md-2 order-first">
<nav aria-label="breadcrumb" class="breadcrumb-header float-start
float-lg-end">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a
href="index.html">Dashboard</a></li>
<li class="breadcrumb-item active" aria-
current="page">Admin</li>
</ol>
</nav>
</div>
</div>
</div>
<section class="row">
<div class="col-12 ">
<div class="row text">
<div class="col-6 ">
<div class="card">
<div class="card-body px-4 py-4-5">
<div class="row">
<div class="col-md-4 col-lg-12 col-xl-12 col-xxl-5
d-flex justify-content-start ">
<div class="stats-icon purple mb-2">
<i class="iconly-boldProfile"></i>
</div>
</div>
<div class="col-md-8 col-lg-12 col-xl-12 col-xxl-
7">
<h6 class="text-muted font-semibold">Total
Mentor</h6>
<?php
$fetchDataSql = "SELECT * FROM mentor ORDER BY mentor_id
DESC";
$fdresult = mysqli_query($conn, $fetchDataSql);
if ($fdresult) {
$rowCount = mysqli_num_rows($fdresult);
echo "<h6 class='font-extrabold mb-0'>$rowCount</h6>";
} else {
echo "Error executing the query: " . mysqli_error($conn);
}
?>
</div>
</div>
</div>
</div>
</div>
<div class="col-6 ">
<div class="card">
<div class="card-body px-4 py-4-5">
<div class="row">
<div class="col-md-4 col-lg-12 col-xl-12 col-xxl-5
d-flex justify-content-start ">
<div class="stats-icon blue mb-2">
<i class="iconly-boldProfile"></i>
</div>
</div>
<div class="col-md-8 col-lg-12 col-xl-12 col-xxl-
7">
<h6 class="text-muted font-semibold">Total
Student</h6>
<?php
$fetchDataSqls = "SELECT * FROM student ORDER BY student_id
DESC";
$fdresults = mysqli_query($conn, $fetchDataSqls);
if ($fdresults) {
$rowCounts = mysqli_num_rows($fdresults);
echo "<h6 class='font-extrabold mb-0'>$rowCounts</h6>";
} else {
echo "Error executing the query: " . mysqli_error($conn);
}
?>
</div>
</div>
</div>
</div>
</div>

</div>
</section>
</div>

<?php
require "../includes/footer.php";
?>

logout.php
<?php
session_start();
session_destroy();
header('location: ../index.php');
?>

mentor.php
<?php

require "../includes/header.php";
require "../includes/conn.php";

if(isset($_SESSION['logged']) && $_SESSION['logged'] == true && $_SESSION['role']


== "Admin"){
}else{
echo "
<script>
window.location.href = '../index.php';
</script>
";
exit;
}
?>

<div class="page-heading">
<div class="page-title">
<div class="row">
<div class="col-12 col-md-6 order-md-1 order-last">
<h3>Student Mentoring System</h3>
</div>
<div class="col-12 col-md-6 order-md-2 order-first">
<nav aria-label="breadcrumb" class="breadcrumb-header float-start
float-lg-end">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a
href="index.html">Mentor</a></li>
<li class="breadcrumb-item active" aria-
current="page">Admin</li>
</ol>
</nav>
</div>
</div>
</div>
<section class="section pt-3">
<div class="card">
<div class="card-body">
<form action="api/api_mentor.php" method="post"
enctype="multipart/form-data">

<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="basicInput">Enter Name</label>
<input type="text" class="form-control"
id="basicInput" name="name"
placeholder="Enter name" required>
</div>

<div class="form-group">
<label for="helpInputTop">Enter email</label>
<input type="email" class="form-control"
placeholder="Enter email" name="email"
required>
<span style="color: red;">username and password
send your register email</span>
</div>
<div class="form-group">
<label for="helpInputTop">Enter Password</label>
<div class="input-group">
<input type="password" class="form-control"
placeholder="Enter Password"
name="password" id="passwordInput"
required>
<button class="btn btn-sm btn-outline-primary"
type="button"
onclick="togglePassword()"><i class="bi bi-
eye-fill"></i></button>
<button class="btn btn-sm btn-outline-primary"
type="button"
onclick="generatePassword()">Generate
Password</button>
</div>
</div>

<div class="form-group">
<label for="helperText">Department</label>
<input type="text" class="form-control"
placeholder="Enter Department" name="department"
required>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="disabledInput">Mobile</label>
<input type="number" class="form-control"
placeholder="Enter Mobile" name="mobile"
required>

</div>

<label for="disabledInput">Gender</label>
<div class="row ms-2 mt-">
<div class="col-3 form-check">
<input class="form-check-input" type="radio"
name="gender" value="male" required>
<label class="form-check-label"
for="flexRadioDefault1">
Male
</label>
</div>

<div class="col-6 form-check">


<input class="form-check-input" type="radio"
name="gender" value="female" required>
<label class="form-check-label"
for="flexRadioDefault1">
Female
</label>
</div>
</div>

<div class="form-group mt-3">


<label for="disabledInput">Date Of Birth</label>
<input type="date" class="form-control"
placeholder="Enter date" name="dob" required
id="helpInputTop">
</div>
<div class="form-group">
<label for="readonlyInput">Select Photo</label>
<input type="file" class="form-control"
placeholder="Select Photo" name="image" required
id="helpInputTop">

</div>
</div>

<div class="col-md-12">
<!-- षह class="btn btn-primary">Primary</a> -->
<button class="btn btn-primary w-100">Submit</button>
</div>
</div>
</form>
</div>
</div>
</section>

<section class="section">
<div class="row" id="table-striped">
<div class="col-12">
<div class="card">

<div class="card-content m-2">


<!-- <div class="card-header">
<h4 class="card-title">Student Details</h4>
</div> -->
<div class="table-responsive">
<table class="table table-striped mb-0">
<thead>
<tr>
<th>S.no</th>
<th>Name</th>
<th>email</th>
<th>gender</th>
<th>mobile</th>
<th>dob</th>
<th>department</th>
<th>photo</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$fetchDataSql = "SELECT * FROM mentor ORDER BY
mentor_id DESC ";
$fdresult = mysqli_query($conn, $fetchDataSql);
$sr = 1;
while ($row = mysqli_fetch_array($fdresult)) {
echo '<tr>
<th scope="row">' . $sr . '</th>
<td>' . $row['name'] . '</td>
<td>' . $row['email'] . '</td>
<td>' . $row['gender'] . '</td>
<td>' . $row['mobile'] . '</td>
<td>' . $row['dob'] . '</td>
<td>' . $row['department'] . '</td>
<td>
<a href="../images/mentor/' . $row['photo'] . '"
target="_blank">
<img src="../images/mentor/' . $row['photo'] . '"
alt="Loading" width="100" height="100" class="img-thumbnail">
</a>
</td> ';
?>

<td>
<a href="update_mentor.php?mentor_id=<?php
echo $row['mentor_id']; ?>"
class="btn btn-primary"><i
class="bi bi-pencil-square"></i></a>
<button class="btn btn-danger"
type="button"
onclick="confirmDelete('<?php echo
$row['mentor_id']; ?>')"><i
class="bi
bi-trash3-fill"></i></button>
</td>
<?php
echo '</tr>';
$sr++;
}
?>
</tbody>
</table>
</div>

</div>
</div>
</div>
</div>
</section>
</div>

<?php
// session_startsession_start();
if (isset($_SESSION['msg'])) {
echo $_SESSION['msg'];
unset($_SESSION['msg']);
}
?>
<script>
function generatePassword() {
const length = 10; // Adjust the length of the password
const charset =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
let password = "";
for (let i = 0; i < length; i++) {
const randomIndex = Math.floor(Math.random() * charset.length);
password += charset[randomIndex];
}

document.getElementById("passwordInput").value = password;
}
function togglePassword() {
var passwordInput = document.getElementById("passwordInput");
if (passwordInput.type === "password") {
passwordInput.type = "text";
} else {
passwordInput.type = "password";
}
}

function confirmDelete(mentor_id) {
// console.log(student_id);
var confirmDeletes = confirm("Are you sure you want to delete mentor
details?");
if (confirmDeletes) {
window.location.href = "api/api_mentor.php?del=" + mentor_id;
}
}
</script>
<?php
require "../includes/footer.php";
?>

notification.php
<?php
require "../includes/header.php";
require "../includes/conn.php";
if(isset($_SESSION['logged']) && $_SESSION['logged'] == true && $_SESSION['role']
== "Admin"){
}else{
echo "
<script>
window.location.href = '../index.php';
</script>
";
exit;
}
?>
<div class="page-heading">
<div class="page-title">
<div class="row">
<div class="col-12 col-md-6 order-md-1 order-last">
<h3>Notification</h3>
<p class="text-subtitle text-muted">Manage Notification</p>
</div>
<div class="col-12 col-md-6 order-md-2 order-first">
<nav aria-label="breadcrumb" class="breadcrumb-header float-start
float-lg-end">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a
href="index.php">Dashboard</a></li>
<li class="breadcrumb-item active" aria-
current="page">Notification</li>
</ol>
</nav>
</div>
</div>
</div>
<section class="section">
<div class="card">
<div class="card-header">
<h4 class="card-title">Send Notification</h4>
</div>
<div class="card-body">
<form class="form form-horizontal"
action="api/api_notification.php" method="POST">
<div class="form-body">
<div class="row">

<div class="col-md-4">
<label for="title">Notification Title</label>
</div>
<div class="col-md-8 form-group">
<input type="text" id="title" rows="5" class="form-
control" name="title" placeholder="Title" required />
</div>

<div class="col-md-4">
<label for="to">To</label>
</div>
<div class="col-md-8 form-group" style="height: 200px;
overflow-y: scroll;">
<div class="checkbox">
<input type="checkbox" onClick="toggle(this)"
class="form-check-input">
<label>All</label>
</div>

<?php
$sqlstud = "SELECT * FROM `student` ORDER BY
student_id DESC";
$resstud = mysqli_query($conn, $sqlstud);
while ($rowstud = mysqli_fetch_assoc($resstud)) {
?>

<div class="checkbox">
<input type="checkbox" name="stud[]"
value="<?php echo $rowstud['fcm_device_token']; ?>" class="form-check-input">
<label><?php echo $rowstud['name'];
?></label>
</div>

<?php
}
?>
</div>

<div class="col-md-4">
<label for="message">Message</label>
</div>
<div class="col-md-8 form-group">
<textarea type="text" id="message" rows="5"
class="form-control" name="message" placeholder="Message" required> </textarea>
</div>

</div>
</div>
<button type="submit" class="btn btn-primary ms-1">
<i class="bx bx-check d-block d-sm-none"></i>
<span class="d-none d-sm-block">Send</span>
</button>
</form>
</div>
</div>
</section>
</div>

<?php
if (isset($_SESSION['msg'])) {
echo $_SESSION['msg'];
unset($_SESSION['msg']);
}
?>

<script language="JavaScript">
function toggle(source) {
checkboxes = document.getElementsByName('stud[]');
for (var i = 0, n = checkboxes.length; i < n; i++) {
checkboxes[i].checked = source.checked;
}
}
</script>

<?php
require "../includes/footer.php";
?>

Student.php
<?php
require "../includes/header.php";
require "../includes/conn.php";

if(isset($_SESSION['logged']) && $_SESSION['logged'] == true && $_SESSION['role']


== "Admin"){
}else{
echo "
<script>
window.location.href = '../index.php';
</script>
";
exit;
}
?>

<div class="page-heading">
<div class="page-title">
<div class="row">
<div class="col-12 col-md-6 order-md-1 order-last">
<h3>Student Mentoring System</h3>
</div>
<div class="col-12 col-md-6 order-md-2 order-first">
<nav aria-label="breadcrumb" class="breadcrumb-header float-start
float-lg-end">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a
href="index.html">Student</a></li>
<li class="breadcrumb-item active" aria-
current="page">Admin</li>
</ol>
</nav>
</div>
</div>
</div>
<section class="section pt-3">
<div class="card">
<div class="card-body">
<form action="api/api_student.php" method="post"
enctype="multipart/form-data">

<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="basicInput">Enter Name</label>
<input type="text" class="form-control"
id="basicInput" name="name"
placeholder="Enter name" required>
</div>

<div class="form-group">
<label for="helpInputTop">Enter email</label>
<input type="email" class="form-control"
placeholder="Enter email" name="email"
required>
<span style="color: red;">username and password
send your register email</span>
</div>
<div class="form-group">
<label for="helpInputTop">Enter Password</label>
<div class="input-group">
<input type="password" class="form-control"
placeholder="Enter Password"
name="password" id="passwordInput"
required>
<button class="btn btn-sm btn-outline-primary"
type="button"
onclick="togglePassword()"><i class="bi bi-
eye-fill"></i></button>
<button class="btn btn-sm btn-outline-primary"
type="button"
onclick="generatePassword()">Generate
Password</button>
</div>
</div>
<div class="form-group">
<label for="helperText">Department</label>
<input type="text" class="form-control"
placeholder="Enter Department" name="department"
required>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="disabledInput">Mobile</label>
<input type="number" class="form-control"
placeholder="Enter Mobile" name="mobile"
required>

</div>

<label for="disabledInput">Gender</label>
<div class="row ms-2 mt-2">
<div class="col-3 form-check">
<input class="form-check-input" type="radio"
name="gender" value="Male" required>
<label class="form-check-label"
for="flexRadioDefault1">
Male
</label>
</div>

<div class="col-6 form-check">


<input class="form-check-input" type="radio"
name="gender" value="Female" required>
<label class="form-check-label"
for="flexRadioDefault1">
Female
</label>
</div>
</div>

<div class="form-group mt-3">


<label for="disabledInput">Date Of Birth</label>
<input type="date" class="form-control"
placeholder="Enter date" name="dob" required
id="helpInputTop">
</div>
<div class="form-group">
<label for="readonlyInput">Select Photo</label>
<input type="file" class="form-control"
placeholder="Select Photo" name="image" required
id="helpInputTop">

</div>
</div>

<div class="col-md-12">
<!-- षह class="btn btn-primary">Primary</a> -->
<button class="btn btn-primary w-100">Submit</button>
</div>
</div>
</form>
</div>
</div>
</section>

<section class="section">
<div class="row" id="table-striped">
<div class="col-12">
<div class="card">

<div class="card-content m-2">


<!-- <div class="card-header">
<h4 class="card-title">Student Details</h4>
</div> -->
<div class="table-responsive">
<table class="table table-striped mb-0">
<thead>
<tr>
<th>S.no</th>
<th>Name</th>
<th>email</th>
<th>gender</th>
<th>mobile</th>
<th>dob</th>
<th>department</th>
<th>photo</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$fetchDataSql = "SELECT * FROM student ORDER BY
student_id DESC ";
$fdresult = mysqli_query($conn, $fetchDataSql);
$sr = 1;
while ($row = mysqli_fetch_array($fdresult)) {
echo '<tr>
<th scope="row">' . $sr . '</th>
<td>' . $row['name'] . '</td>
<td>' . $row['email'] . '</td>
<td>' . $row['gender'] . '</td>
<td>' . $row['mobile'] . '</td>
<td>' . $row['dob'] . '</td>
<td>' . $row['department'] . '</td>
<td>
<a href="../images/' . $row['photo'] . '" target="_blank">
<img src="../images/' . $row['photo'] . '"
alt="Loading" width="100" height="100" class="img-thumbnail">
</a>
</td> ';
?>

<td>
<a href="update_student.php?
student_id=<?php echo $row['student_id']; ?>"
class="btn btn-primary"><i
class="bi bi-pencil-square"></i></a>
<button class="btn btn-danger"
type="button"
onclick="confirmDelete(<?php echo
$row['student_id']; ?>)"><i
class="bi
bi-trash3-fill"></i></button>
</td>
<?php
echo '</tr>';
$sr++;
}
?>
</tbody>
</table>
</div>

</div>
</div>
</div>
</div>
</section>
</div>

<?php
// session_startsession_start();
if (isset($_SESSION['msg'])) {
echo $_SESSION['msg'];
unset($_SESSION['msg']);
}
?>
<script>
function generatePassword() {
const length = 10; // Adjust the length of the password
const charset =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
let password = "";

for (let i = 0; i < length; i++) {


const randomIndex = Math.floor(Math.random() * charset.length);
password += charset[randomIndex];
}

document.getElementById("passwordInput").value = password;
}
function togglePassword() {
var passwordInput = document.getElementById("passwordInput");
if (passwordInput.type === "password") {
passwordInput.type = "text";
} else {
passwordInput.type = "password";
}
}

function confirmDelete(student_id) {
console.log(student_id);
var confirmDeletes = confirm("Are you delete student details...?");
if (confirmDeletes) {
window.location.href = `api/api_student.php?del=${student_id}`;
}
}
</script>
<?php
require "../includes/footer.php";
?>

update_mentor.php
<?php

require "../includes/header.php";
require "../includes/conn.php";

if(isset($_SESSION['logged']) && $_SESSION['logged'] == true && $_SESSION['role']


== "Admin"){
}else{
echo "
<script>
window.location.href = '../index.php';
</script>
";
exit;
}
$studentId = mysqli_real_escape_string($conn, $_GET['mentor_id']);
$fetchDataSql = "SELECT * FROM mentor WHERE mentor_id = $studentId ORDER BY
mentor_id DESC";
$fdresult = mysqli_query($conn, $fetchDataSql);
$row = mysqli_fetch_array($fdresult);

// die($row['name']);
?>

<div class="page-heading">
<div class="page-title">
<div class="row">
<div class="col-12 col-md-6 order-md-1 order-last">
<h3>Student Mentoring System</h3>
</div>
<div class="col-12 col-md-6 order-md-2 order-first">
<nav aria-label="breadcrumb" class="breadcrumb-header float-start
float-lg-end">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="index.html">Update
Mentor</a></li>
<li class="breadcrumb-item active" aria-
current="page">Admin</li>
</ol>
</nav>
</div>
</div>
</div>
<section class="section pt-3">
<div class="card">
<div class="card-body">
<form action="api/api_mentor.php" method="post"
enctype="multipart/form-data">
<div class="row">
<div class="col-md-6">
<input type="text" class="form-control" id="basicInput"
name="updateid" value="<?php echo $row['mentor_id']; ?>" required >
<div class="form-group">
<label for="basicInput">Enter Name</label>
<input type="text" class="form-control"
id="basicInput" name="updatename" placeholder="Enter name" value="<?php echo
$row['name']; ?>" required>
</div>

<div class="form-group">
<label for="helpInputTop">Enter email</label>
<input type="email" class="form-control" value="<?
php echo $row['email']; ?>"
name="updateemail" readonly>
</div>
<div class="form-group">

<label for="helpInputTop">Enter New Password<span


style="color: red;">(Optional)</span> </label>
<div class="input-group">
<input type="password" class="form-control"
placeholder="Enter New Password"
name="updatepassword" id="passwordInput" >
<button class="btn btn-sm btn-outline-primary"
type="button"
onclick="togglePassword()"><i class="bi bi-
eye-fill"></i></button>
<button class="btn btn-sm btn-outline-primary"
type="button"
onclick="generatePassword()">Generate
Password</button>
</div>
</div>

<div class="form-group">
<label for="helperText">Department</label>
<input type="text" class="form-control"
placeholder="Enter Department" name="updatedepartment" value="<?php echo
$row['department']; ?>"
required>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="disabledInput">Mobile</label>
<input type="number" class="form-control"
placeholder="Enter Mobile" name="updatemobile" value="<?php echo $row['mobile']; ?
>"
required>

</div>
<!-- <label for="department">Gender</label> -->
<fieldset class="form-group pt-4">
<select class="form-select"
id="basicSelect" name="updategender">
<?php
$genders = array('Male', 'Female');
$storedGender = $row['gender'];
foreach ($genders as $gender) {
$selected = ($gender == $storedGender) ? 'selected' : '';
echo "<option value=\"$gender\" $selected>$gender</option>";
}
?>
</select>
</fieldset>

<div class="form-group mt-3">


<label for="disabledInput">Date Of Birth</label>
<input type="date" class="form-control"
placeholder="Enter date" name="updatedob" required value="<?php echo $row['dob']; ?
>"
id="helpInputTop">
</div>

<div class="form-group">
<label for="helperText">Select Image</label>
<input type="file" class="form-control"
placeholder="Enter Department" name="updateimage"
>
</div>
</div>

<div class="col-md-12">
<button class="btn btn-primary w-100">Submit</button>
</div>
</div>
</form>
</div>
</div>
</section>

</div>

<?php
// session_startsession_start();
if (isset($_SESSION['msg'])) {
echo $_SESSION['msg'];
unset($_SESSION['msg']);
}
?>
<script>
function generatePassword() {
const length = 10; // Adjust the length of the password
const charset =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
let password = "";

for (let i = 0; i < length; i++) {


const randomIndex = Math.floor(Math.random() * charset.length);
password += charset[randomIndex];
}

document.getElementById("passwordInput").value = password;
}
function togglePassword() {
var passwordInput = document.getElementById("passwordInput");
if (passwordInput.type === "password") {
passwordInput.type = "text";
} else {
passwordInput.type = "password";
}
}

</script>
<?php
require "../includes/footer.php";
?>

update_Student.php
<?php

require "../includes/header.php";
require "../includes/conn.php";

if(isset($_SESSION['logged']) && $_SESSION['logged'] == true && $_SESSION['role']


== "Admin"){
}else{
echo "
<script>
window.location.href = '../index.php';
</script>
";
exit;
}
$studentId = mysqli_real_escape_string($conn, $_GET['student_id']);
$fetchDataSql = "SELECT * FROM student WHERE student_id = $studentId ORDER BY
student_id DESC";
$fdresult = mysqli_query($conn, $fetchDataSql);
$row = mysqli_fetch_array($fdresult);

// die($row['name']);
?>

<div class="page-heading">
<div class="page-title">
<div class="row">
<div class="col-12 col-md-6 order-md-1 order-last">
<h3>Student Mentoring System</h3>
</div>
<div class="col-12 col-md-6 order-md-2 order-first">
<nav aria-label="breadcrumb" class="breadcrumb-header float-start
float-lg-end">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="index.html">Update
Student</a></li>
<li class="breadcrumb-item active" aria-
current="page">Admin</li>
</ol>
</nav>
</div>
</div>
</div>
<section class="section pt-3">
<div class="card">
<div class="card-body">
<form action="api/api_student.php" method="post"
enctype="multipart/form-data">
<div class="row">
<div class="col-md-6">
<input type="text" class="form-control" id="basicInput"
name="updateid" value="<?php echo $row['student_id']; ?>" required hidden>
<div class="form-group">
<label for="basicInput">Enter Name</label>
<input type="text" class="form-control"
id="basicInput" name="updatename" placeholder="Enter name" value="<?php echo
$row['name']; ?>" required>
</div>

<div class="form-group">
<label for="helpInputTop">Enter email</label>
<input type="email" class="form-control" value="<?
php echo $row['email']; ?>"
name="updateemail" readonly>
</div>
<div class="form-group">

<label for="helpInputTop">Enter New Password<span


style="color: red;">(Optional)</span> </label>
<div class="input-group">
<input type="password" class="form-control"
placeholder="Enter New Password"
name="updatepassword" id="passwordInput" >
<button class="btn btn-sm btn-outline-primary"
type="button"
onclick="togglePassword()"><i class="bi bi-
eye-fill"></i></button>
<button class="btn btn-sm btn-outline-primary"
type="button"
onclick="generatePassword()">Generate
Password</button>
</div>
</div>

<div class="form-group">
<label for="helperText">Department</label>
<input type="text" class="form-control"
placeholder="Enter Department" name="updatedepartment" value="<?php echo
$row['department']; ?>"
required>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="disabledInput">Mobile</label>
<input type="number" class="form-control"
placeholder="Enter Mobile" name="updatemobile" value="<?php echo $row['mobile']; ?
>"
required>

</div>
<!-- <label for="department">Gender</label> -->
<fieldset class="form-group pt-4">
<select class="form-select"
id="basicSelect" name="updategender">
<?php
$genders = array('Male', 'Female');
$storedGender = $row['gender'];
foreach ($genders as $gender) {
$selected = ($gender == $storedGender) ? 'selected' : '';
echo "<option value=\"$gender\" $selected>$gender</option>";
}
?>
</select>
</fieldset>

<div class="form-group mt-3">


<label for="disabledInput">Date Of Birth</label>
<input type="date" class="form-control"
placeholder="Enter date" name="updatedob" required value="<?php echo $row['dob']; ?
>"
id="helpInputTop">
</div>

<div class="form-group">
<label for="helperText">Select Image</label>
<input type="file" class="form-control"
placeholder="Enter Department" name="updateimage"
>
</div>
</div>

<div class="col-md-12">
<button class="btn btn-primary w-100">Submit</button>
</div>
</div>
</form>
</div>
</div>
</section>

</div>

<?php
// session_startsession_start();
if (isset($_SESSION['msg'])) {
echo $_SESSION['msg'];
unset($_SESSION['msg']);
}
?>
<script>
function generatePassword() {
const length = 10; // Adjust the length of the password
const charset =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
let password = "";

for (let i = 0; i < length; i++) {


const randomIndex = Math.floor(Math.random() * charset.length);
password += charset[randomIndex];
}
document.getElementById("passwordInput").value = password;
}
function togglePassword() {
var passwordInput = document.getElementById("passwordInput");
if (passwordInput.type === "password") {
passwordInput.type = "text";
} else {
passwordInput.type = "password";
}
}

</script>
<?php
require "../includes/footer.php";
?>

Mentor
api_doubt.php
<?php
session_start();
if(isset($_SESSION['logged']) && $_SESSION['logged'] == true && $_SESSION['role']
== "Mentor"){
require "../../includes/conn.php";
}else{
echo "
<script>
window.location.href = '../../index.php';
</script>
";
exit;
}
if(isset($_POST['id']) && isset($_POST['student_id'])){
$id = mysqli_escape_string($conn,$_POST['id']);
$student_id = mysqli_escape_string($conn,$_POST['student_id']);
$dobut = mysqli_escape_string($conn,$_POST['dobut']);
$reply = mysqli_escape_string($conn,$_POST['reply']);
$mentorID = $_SESSION['mentor_id'];

$sql = "UPDATE `doubts` SET `mentor_id`='$mentorID',`reply`='$reply' WHERE


`id`=$id";
$res = mysqli_query($conn, $sql);
if ($res) {
session_start();
$_SESSION['msg'] = '<script>
Toastify({
text: "Reply Send.",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "#0B8803",
}).showToast()

</script>';

header('location: ../doubts.php');
exit;
// echo "instered";
} else {
session_start();
$_SESSION['msg'] = '<script>
Toastify({
text: "Something Went Wrong.",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "#F7360D",
}).showToast()

</script>';

header('location: ../doubts.php');
exit;
}
}
?>

api_meeting.php
<?php
session_start();
if(isset($_SESSION['logged']) && $_SESSION['logged'] == true && $_SESSION['role']
== "Mentor"){
require "../../includes/conn.php";
}else{
echo "
<script>
window.location.href = '../../index.php';
</script>
";
exit;
}
if (isset($_POST['title']) && isset($_POST['date'])) {
$title = mysqli_escape_string($conn, $_POST['title']);
$date = mysqli_escape_string($conn, $_POST['date']);
$time = mysqli_escape_string($conn, $_POST['time']);
$password = mysqli_escape_string($conn, $_POST['password']);
$meetinglink = mysqli_escape_string($conn, $_POST['meetinglink']);

// print_r($_POST);
$mentorID = $_SESSION['mentor_id'];

$sql = "INSERT INTO `meeting`(`title`, `meeting_link`, `time`, `date`,


`mentor_id`, `meeting_password`) VALUES
('$title','$meetinglink','$time','$date','$mentorID','$password')";
$res = mysqli_query($conn, $sql);
if ($res) {
session_start();
$_SESSION['msg'] = '<script>
Toastify({
text: "Zoom Meeting Added.",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "#0B8803",
}).showToast()

</script>';

header('location: ../meetings.php');
exit;
// echo "instered";
} else {
session_start();
$_SESSION['msg'] = '<script>
Toastify({
text: "Something Went Wrong.",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "#F7360D",
}).showToast()

</script>';

header('location: ../meetings.php');
exit;
}
} elseif (isset($_GET['id']) && isset($_GET['type']) == "del") {
$id = $_GET['id'];
$sql = "DELETE FROM `meeting` WHERE id=$id";
$res = mysqli_query($conn, $sql);
if ($res) {
session_start();
$_SESSION['msg'] = '<script>
Toastify({
text: "Zoom Meeting Deleted.",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "#0B8803",
}).showToast()

</script>';

header('location: ../meetings.php');
exit;
// echo "instered";
} else {
session_start();
$_SESSION['msg'] = '<script>
Toastify({
text: "Something Went Wrong.",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "#F7360D",
}).showToast()

</script>';
header('location: ../meetings.php');
exit;
}
}

api_notification.php
<?php
session_start();
if(isset($_SESSION['logged']) && $_SESSION['logged'] == true && $_SESSION['role']
== "Mentor"){
require "../../includes/conn.php";
}else{
echo "
<script>
window.location.href = '../../index.php';
</script>
";
exit;
}
if (isset($_POST['title']) && isset($_POST['date'])) {
$title = mysqli_escape_string($conn, $_POST['title']);
$date = mysqli_escape_string($conn, $_POST['date']);
$time = mysqli_escape_string($conn, $_POST['time']);
$password = mysqli_escape_string($conn, $_POST['password']);
$meetinglink = mysqli_escape_string($conn, $_POST['meetinglink']);

// print_r($_POST);
$mentorID = $_SESSION['mentor_id'];

$sql = "INSERT INTO `meeting`(`title`, `meeting_link`, `time`, `date`,


`mentor_id`, `meeting_password`) VALUES
('$title','$meetinglink','$time','$date','$mentorID','$password')";
$res = mysqli_query($conn, $sql);
if ($res) {
session_start();
$_SESSION['msg'] = '<script>
Toastify({
text: "Zoom Meeting Added.",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "#0B8803",
}).showToast()

</script>';

header('location: ../meetings.php');
exit;
// echo "instered";
} else {
session_start();
$_SESSION['msg'] = '<script>
Toastify({
text: "Something Went Wrong.",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "#F7360D",
}).showToast()

</script>';

header('location: ../meetings.php');
exit;
}
} elseif (isset($_GET['id']) && isset($_GET['type']) == "del") {
$id = $_GET['id'];
$sql = "DELETE FROM `meeting` WHERE id=$id";
$res = mysqli_query($conn, $sql);
if ($res) {
session_start();
$_SESSION['msg'] = '<script>
Toastify({
text: "Zoom Meeting Deleted.",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "#0B8803",
}).showToast()

</script>';

header('location: ../meetings.php');
exit;
// echo "instered";
} else {
session_start();
$_SESSION['msg'] = '<script>
Toastify({
text: "Something Went Wrong.",
duration: 3000,
close: true,
gravity: "top",
position: "center",
backgroundColor: "#F7360D",
}).showToast()

</script>';

header('location: ../meetings.php');
exit;
}
}

blank.php
<?php
require "includes/header.php";
?>

<div class="page-heading">
<div class="page-title">
<div class="row">
<div class="col-12 col-md-6 order-md-1 order-last">
<h3>Layout Default</h3>
<p class="text-subtitle text-muted">The default layout.</p>
</div>
<div class="col-12 col-md-6 order-md-2 order-first">
<nav aria-label="breadcrumb" class="breadcrumb-header float-start
float-lg-end">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a
href="index.html">Dashboard</a></li>
<li class="breadcrumb-item active" aria-
current="page">Layout Default</li>
</ol>
</nav>
</div>
</div>
</div>
<section class="section">
<div class="card">
<div class="card-header">
<h4 class="card-title">Default Layout</h4>
</div>
<div class="card-body">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Magnam,
commodi? Ullam quaerat similique iusto
temporibus, vero aliquam praesentium, odit deserunt eaque nihil
saepe hic deleniti? Placeat delectus
quibusdam ratione ullam!
</div>
</div>
</section>
</div>

<?php
require "includes/footer.php";
?>

doubt.php
<?php
require "../includes/header.php";
require "../includes/conn.php";
if(isset($_SESSION['logged']) && $_SESSION['logged'] == true && $_SESSION['role']
== "Mentor"){
}else{
echo "
<script>
window.location.href = '../index.php';
</script>
";
exit;
}
?>
<div class="page-heading">
<div class="page-title">
<div class="row">
<div class="col-12 col-md-6 order-md-1 order-last">
<h3>Doubts</h3>
<p class="text-subtitle text-muted">Manage Doubts</p>
</div>
<div class="col-12 col-md-6 order-md-2 order-first">
<nav aria-label="breadcrumb" class="breadcrumb-header float-start
float-lg-end">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a
href="index.php">Dashboard</a></li>
<li class="breadcrumb-item active" aria-
current="page">Doubts</li>
</ol>
</nav>
</div>
</div>
</div>
<section class="section">
<div class="card">
<div class="card-header">
<h4 class="card-title">Default Layout</h4>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-striped table-bordered mb-0">
<thead>
<tr>
<th>PHOTO</th>
<th>NAME</th>
<th>DEPARTMENT</th>
<th>GENDER</th>
<th>DOUBT</th>
<th>REPLY</th>
</tr>
</thead>
<tbody>
<?php
$sql1 = "SELECT * FROM `doubts` ORDER BY `id` DESC";
$res1 = mysqli_query($conn, $sql1);
while ($rowd = mysqli_fetch_assoc($res1)) {
$sql12 = "SELECT * FROM `student` WHERE
`student_id`=" . $rowd['student_id'];
$res12 = mysqli_query($conn, $sql12);
$rowd2 = mysqli_fetch_assoc($res12);
?>
<tr>
<td><img src="../images/<?php echo
$rowd2['photo']; ?>" alt="" width="100px"></td>
<td><?php echo $rowd2['name']; ?></td>
<td><?php echo $rowd2['department']; ?></td>
<td><?php echo $rowd2['gender']; ?></td>
<td><?php echo $rowd['doubt']; ?></td>
<td>
<?php
if ($rowd['reply'] == null) {;
?>
<button href="#" onclick="replyModel(<?
php echo $rowd['id']; ?>,<?php echo $rowd['student_id']; ?>,'<?php echo
$rowd['doubt']; ?>')" class="btn btn-primary">
<svg
xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
class="bi bi-reply-fill" viewBox="0 0 16 16">
<path d="M5.921 11.9 1.353
8.62a.72.72 0 0 1 0-1.238L5.921 4.1A.716.716 0 0 1 7 4.719V6c1.5 0 6 0 7 8-2.5-4.5-
7-4-7-4v1.281c0 .56-.606.898-1.079.62z" />
</svg> Reply
</button>
</td>
<?php
}else{
echo $rowd['reply'];
}
?>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
</section>
</div>

<!-- <?php echo 'id'; ?>,<?php echo 'studid'; ?>,'<?php echo


htmlspecialchars('doubt'); ?>' -->
<!--Basic Modal -->
<div class="modal fade text-left" id="default" tabindex="-1" role="dialog" aria-
labelledby="myModalLabel1" aria-hidden="true">
<div class="modal-dialog modal-dialog-scrollable" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="myModalLabel1">Reply</h5>
<button type="button" class="close rounded-pill" data-bs-
dismiss="modal" aria-label="Close">
<i data-feather="x"></i>
</button>
</div>
<div class="modal-body">
<form class="form form-horizontal" action="api/api_doubt.php"
method="POST">
<div class="form-body">
<div class="row">
<input type="text" name="id" id="id" hidden>
<input type="text" name="student_id" id="student_id"
hidden>
<div class="col-md-4">
<label for="dobut">Doubt</label>
</div>
<div class="col-md-8 form-group">
<textarea type="text" id="dobut" class="form-
control" name="doubt" placeholder="Doubt" readonly></textarea>
</div>

<div class="col-md-4">
<label for="reply">Reply</label>
</div>
<div class="col-md-8 form-group">
<textarea type="text" id="reply" class="form-
control" name="reply" placeholder="Reply" required></textarea>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary ms-1">
<i class="bx bx-check d-block d-sm-none"></i>
<span class="d-none d-sm-block">Submit</span>
</button>
</div>
</form>
</div>
</div>
</div>

<script>
function replyModel(id, student_id, doubt) {
$('#dobut').val(doubt);
$('#student_id').val(student_id);
$('#id').val(id);
$('#default').modal('toggle');
}
</script>

<?php
if (isset($_SESSION['msg'])) {
echo $_SESSION['msg'];
unset($_SESSION['msg']);
}
?>

<?php
require "../includes/footer.php";
?>

index.php
<?php
require "../includes/header.php";
if(isset($_SESSION['logged']) && $_SESSION['logged'] == true && $_SESSION['role']
== "Mentor"){
}else{
echo "
<script>
window.location.href = '../index.php';
</script>
";
exit;
}
?>

<div class="page-heading">
<h3>Dashboard</h3>
</div>
<div class="page-content">
<section class="section">
<div class="card">
<div class="card-header">
<h4 class="card-title">Welcome, <?php echo $_SESSION['name']; ?></h4>
</div>
<div class="card-body">
</div>
</section>
</div>

<?php
require "../includes/footer.php";
?>

logout.php
<?php
session_start();
session_destroy();
header('location: ../index.php');
?>

meetings.php

<?php
require "../includes/header.php";
require "../includes/conn.php";
if(isset($_SESSION['logged']) && $_SESSION['logged'] == true && $_SESSION['role']
== "Mentor"){
}else{
echo "
<script>
window.location.href = '../index.php';
</script>
";
exit;
}
?>
<div class="page-heading">
<div class="page-title">
<div class="row">
<div class="col-12 col-md-6 order-md-1 order-last">
<h3>Zoom Meetings</h3>
<p class="text-subtitle text-muted">Manage Zoom Meetings</p>
</div>
<div class="col-12 col-md-6 order-md-2 order-first">
<nav aria-label="breadcrumb" class="breadcrumb-header float-start
float-lg-end">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a
href="index.php">Dashboard</a></li>
<li class="breadcrumb-item active" aria-current="page">Zoom
Meetings</li>
</ol>
</nav>
</div>
</div>
</div>
<section class="section">
<div class="my-3 text-center">
<button class="btn btn-primary" data-bs-toggle="modal" data-bs-
target="#default">Add Meeting</button>
</div>
<div class="card">
<div class="card-header">
<h4 class="card-title">All Zoom Meetings</h4>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-striped table-bordered mb-0">
<thead>
<tr>
<th>TITLE</th>
<th>DATE</th>
<th>TIME</th>
<th>MEETING LINK</th>
<th>MEETING PASSWORD</th>
<th>ACTION</th>
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT * FROM `meeting` ORDER BY id DESC";
$res = mysqli_query($conn, $sql);
while ($row = mysqli_fetch_assoc($res)) {
?>

<tr>
<td class="text-bold-500"><?php echo
$row['title']; ?></td>
<td><?php echo $row['date']; ?></td>
<td class="text-bold-500"><?php echo
$row['time']; ?></td>
<td><?php echo $row['meeting_link']; ?></td>
<td><?php echo $row['meeting_password'];
?></td>
<td>
<button href="#" onclick="deleteapi(<?php
echo $row['id']; ?>)" class="btn btn-danger">
<svg xmlns="http://www.w3.org/2000/svg"
width="16" height="16" fill="currentColor" class="bi bi-trash" viewBox="0 0 16 16">
<path d="M5.5 5.5A.5.5 0 0 1 6
6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5m2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5
0 0 1 .5-.5m3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0z" />
<path d="M14.5 3a1 1 0 0 1-1
1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0
1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1zM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0
0 1-1V4.059L11.882 4zM2.5 3h11V2h-11z" />
</svg>
</button>
</td>
</tr>

<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
</section>
</div>

<!-- <?php echo 'id'; ?>,<?php echo 'studid'; ?>,'<?php echo


htmlspecialchars('doubt'); ?>' -->
<!--Basic Modal -->
<div class="modal fade text-left" id="default" tabindex="-1" role="dialog" aria-
labelledby="myModalLabel1" aria-hidden="true">
<div class="modal-dialog modal-dialog-scrollable" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="myModalLabel1">Add New Meeting</h5>
<button type="button" class="close rounded-pill" data-bs-
dismiss="modal" aria-label="Close">
<i data-feather="x"></i>
</button>
</div>
<div class="modal-body">
<form class="form form-horizontal" action="api/api_meeting.php"
method="POST">
<div class="form-body">
<div class="row">
<div class="col-md-4">
<label for="Title">Title</label>
</div>
<div class="col-md-8 form-group">
<input type="text" id="Title" class="form-control"
name="title" placeholder="Title" required />
</div>

<div class="col-md-4">
<label for="Date">Date</label>
</div>
<div class="col-md-8 form-group">
<input type="date" id="Date" class="form-control"
name="date" placeholder="Date" required></input>
</div>

<div class="col-md-4">
<label for="Time">Time</label>
</div>
<div class="col-md-8 form-group">
<input type="time" id="Time" class="form-control"
name="time" placeholder="Time" required></input>
</div>

<div class="col-md-4">
<label for="Password">Meeting Password</label>
</div>
<div class="col-md-8 form-group">
<input type="text" id="Password" class="form-
control" name="password" placeholder="Password Time" required></input>
</div>

<div class="col-md-4">
<label for="meetinglink">Meeting Link</label>
</div>
<div class="col-md-8 form-group">
<input type="url" id="meetinglink" class="form-
control" name="meetinglink" placeholder="Meeting Link" required></input>
</div>

</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary ms-1">
<i class="bx bx-check d-block d-sm-none"></i>
<span class="d-none d-sm-block">Submit</span>
</button>
</div>
</form>
</div>
</div>
</div>

<?php
if (isset($_SESSION['msg'])) {
echo $_SESSION['msg'];
unset($_SESSION['msg']);
}
?>

<script>
function replyModel() {
$('#default').modal('toggle');
}

function deleteapi(id) {
let isDeleted= confirm("Are you sure to delete?");
if (isDeleted) {
window.location.href = "api/api_meeting.php?type=del&id="+id;
}
}

// Toastify({
// text: "This is toast in top center",
// duration: 3000,
// close: true,
// gravity: "top",
// position: "center",
// backgroundColor: "#0B8803",
// }).showToast()
</script>

<?php
require "../includes/footer.php";
?>

notification.php

<?php
require "../includes/header.php";
require "../includes/conn.php";
if(isset($_SESSION['logged']) && $_SESSION['logged'] == true && $_SESSION['role']
== "Mentor"){
}else{
echo "
<script>
window.location.href = '../index.php';
</script>
";
exit;
}
?>
<div class="page-heading">
<div class="page-title">
<div class="row">
<div class="col-12 col-md-6 order-md-1 order-last">
<h3>Notification</h3>
<p class="text-subtitle text-muted">Manage Notification</p>
</div>
<div class="col-12 col-md-6 order-md-2 order-first">
<nav aria-label="breadcrumb" class="breadcrumb-header float-start
float-lg-end">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a
href="index.php">Dashboard</a></li>
<li class="breadcrumb-item active" aria-
current="page">Notification</li>
</ol>
</nav>
</div>
</div>
</div>
<section class="section">
<div class="card">
<div class="card-header">
<h4 class="card-title">Send Notification</h4>
</div>
<div class="card-body">
<form class="form form-horizontal"
action="api/api_notification.php" method="POST">
<div class="form-body">
<div class="row">

<div class="col-md-4">
<label for="title">Notification Title</label>
</div>
<div class="col-md-8 form-group">
<input type="text" id="title" rows="5" class="form-
control" name="title" placeholder="Title" required />
</div>

<div class="col-md-4">
<label for="to">To</label>
</div>
<div class="col-md-8 form-group" style="height: 200px;
overflow-y: scroll;">
<div class="checkbox">
<input type="checkbox" onClick="toggle(this)"
class="form-check-input">
<label>All</label>
</div>

<?php
$sqlstud = "SELECT * FROM `student` ORDER BY
student_id DESC";
$resstud = mysqli_query($conn, $sqlstud);
while ($rowstud = mysqli_fetch_assoc($resstud)) {
?>

<div class="checkbox">
<input type="checkbox" name="stud[]"
value="<?php echo $rowstud['fcm_device_token']; ?>" class="form-check-input">
<label><?php echo $rowstud['name'];
?></label>
</div>

<?php
}
?>
</div>

<div class="col-md-4">
<label for="message">Message</label>
</div>
<div class="col-md-8 form-group">
<textarea type="text" id="message" rows="5"
class="form-control" name="message" placeholder="Message" required> </textarea>
</div>

</div>
</div>
<button type="submit" class="btn btn-primary ms-1">
<i class="bx bx-check d-block d-sm-none"></i>
<span class="d-none d-sm-block">Send</span>
</button>
</form>
</div>
</div>
</section>
</div>

<?php
if (isset($_SESSION['msg'])) {
echo $_SESSION['msg'];
unset($_SESSION['msg']);
}
?>

<script language="JavaScript">
function toggle(source) {
checkboxes = document.getElementsByName('stud[]');
for (var i = 0, n = checkboxes.length; i < n; i++) {
checkboxes[i].checked = source.checked;
}
}
</script>

<?php
require "../includes/footer.php";
?>

You might also like