Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $name = trim(strip_tags(stripslashes($_POST['yname'])));
- $q1 = trim(strip_tags(stripslashes($_POST['q1'])));
- $q2 = trim(strip_tags(stripslashes($_POST['q2'])));
- $q3 = trim(strip_tags(stripslashes($_POST['q3'])));
- $q4 = trim(strip_tags(stripslashes($_POST['q4'])));
- $path_to_names_file = $_SERVER['DOCUMENT_ROOT'] . '/../names.txt';
- if ($name <> "" && $q1 <> "" && $q2 <> "" && $q3 <> "" && $q4 <> "") {
- if ($passing > 85) { //value checked in the more comprehensive script
- if(file_exists($path_to_names_file) && $names = file($path_to_names_file) && in_array($name, $names){
- echo "Sorry, but you took the exam already"; //$name has already taken exam
- }
- else { //if name doesn't match, the user is taking it first time. write the name to file for future check
- file_put_contents($path_to_names_file, "$name\n", FILE_APPEND); //append the file
- //....
- }
- }
- else {
- //...
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement