<!DOCTYPE html>
<html>
<body bgcolor="#E6E6FA">

<!-- MODULE COORDINATES -->


<?php
$modulecode= basename(getcwd());
$errorMsg = "";
$validUser = $_SESSION["login"] === true;
if(isset($_POST["submit"])) {
  $validUser = $_POST["username"] == $modulecode && $_POST["password"] == strrev($modulecode);
  if(!$validUser) {$errorMsg = "Invalid username or password.";
  header("Location: error.html");}
  else $_SESSION["login"] = true;
}
?>


<?php
$myfile = fopen("ModuleName.ssi", "r") or die("Unable to open file!");
$name=fread($myfile,filesize("ModuleName.ssi"));
fclose($myfile); ?>




<?php
$tfile = $_FILES["file"];

if (empty($tfile)){}
else { if  ($validUser){
$Lp="uploads/exam.pdf";
 $targetfolder = $Lp;
 $ok=1;
$file_type=$_FILES['file']['type'];
if ($file_type=="application/pdf") {
 if(move_uploaded_file($_FILES['file']['tmp_name'], $targetfolder))
 {
 echo "The file ". basename( $_FILES['file']['name']). " is uploaded";
 }
 else {
 echo "Problem uploading file";
 }
}
else {
 echo "You may only upload PDF files and you need a valid username and password.<br>";
}}
else { header("Location: error.html");}
}

?>






<form action="" method="post" enctype="multipart/form-data">

<p/>
<BR><BR>
<h1>Upload a sample exam paper for <?php echo $name; ?></h2>

<font size="4"><B> Enter your 
    <label for="username">Username:</label><input type="text" value="<?= $_POST["username"] ?>" id="username" name="username" />
and 
    <label for="password">Password:</label><input type="password" value="" id="password" name="password" />
 and then upload the exam paper as a single pdf file:&nbsp;</B></font>
<input type="file" name="file" size="10" />
<input type="submit" name="submit" value="Upload" />
</form>














</body>
</html>


