Question: 0 ) { $message = You have already submitted an excuse for this course.; } else { if ( ! is _ dir ( $targetDir

0){
$message = "You have already submitted an excuse for this course.";
} else {
if (!is_dir($targetDir)){
mkdir($targetDir, 0777, true);
}
//name of ex
$fileName = isset($_FILES["excuse_file"]["name"])? uniqid()."_". basename($_FILES["excuse_file"]["name"]) : '';
$targetFilePath = $targetDir . $fileName;
if (!empty($_FILES["excuse_file"]["name"])){
$fileType = strtolower(pathinfo($targetFilePath, PATHINFO_EXTENSION));
$allowedTypes =["pdf","jpg","png", "jpeg"];
$maxFileSize =5*1024*1024;
if (in_array($fileType, $allowedTypes)){
if ($_FILES["excuse_file"]["size"]<= $maxFileSize){
if ($conn){
$stmt = mysqli_prepare($conn, "INSERT INTO excuses (scheduleID, fileName, status, studentID) VALUES (?,?,?,?)");
mysqli_stmt_bind_param($stmt,"ssss", $scheduleID, $fileName, $status, $studentID);
$executeResult = mysqli_stmt_execute($stmt);
if ($executeResult && move_uploaded_file($_FILES["excuse_file"]["tmp_name"], $targetFilePath)){
$message = "Excuse successfully submitted!";
echo "
alert('Excuse successfully submitted!');
window.location.href = 'view_exam_schedule.php';
";
exit;
} else {
$message = "There was an error uploading the file or submitting the excuse.";
}
mysqli_stmt_close($stmt);
} else {
$message = "Database connection failed.";
}
} else {
$message = "File size exceeds the allowed limit (5 MB).";
}
} else {
$message = "Unsupported file format. Allowed formats: pdf, jpg, png.";
}
} else {
$message = "Please attach a file.";
}
}
}
?> i need to assign schudualID and StudentID by defult not to make user entered

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!