Advertisement
Guest User

Untitled

a guest
Jun 19th, 2013
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 KB | None | 0 0
  1.     <?php
  2.     $name = trim(strip_tags(stripslashes($_POST['yname'])));
  3.     $q1 = trim(strip_tags(stripslashes($_POST['q1'])));
  4.     $q2 = trim(strip_tags(stripslashes($_POST['q2'])));
  5.     $q3 = trim(strip_tags(stripslashes($_POST['q3'])));
  6.     $q4 = trim(strip_tags(stripslashes($_POST['q4'])));
  7.    
  8.     $path_to_names_file = $_SERVER['DOCUMENT_ROOT'] . '/../names.txt';
  9.    
  10.     if ($name <> "" && $q1 <> "" && $q2 <> "" && $q3 <> "" && $q4 <> "") {
  11.         if ($passing > 85) { //value checked in the more comprehensive script
  12.             if(file_exists($path_to_names_file) && $names = file($path_to_names_file) && in_array($name, $names){
  13.                 echo "Sorry, but you took the exam already"; //$name has already taken exam
  14.             }
  15.             else { //if name doesn't match, the user is taking it first time. write the name to file for future check
  16.                 file_put_contents($path_to_names_file, "$name\n", FILE_APPEND); //append the file
  17.                 //....
  18.             }
  19.         }
  20.         else {
  21.             //...
  22.         }
  23.     }
  24.     ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement