fork download
  1. <?php
  2.  
  3.  
  4. $student = array('DatafirstName', 'DatalastName', 'Datasex', 'Datasection', 'Dataemail', 'Datayear', 'Dataexams', 'DataisLocal');
  5. $example = array('firstName', 'lastName', 'sex', 'section', 'email', 'year', 'exams', 'isLocal');
  6.  
  7. //foreach ($example as $field) {
  8. // $student[] = $_POST[$field];
  9. //}
  10.  
  11. try {
  12. $DHB = new PDO('mysql:host = localhost;dbname = sat', 'root', '');
  13. $STH = $DHB->prepare("SELECT email FROM students WHERE email = ?");
  14. $STH->bindparam(1, $email);
  15. $email = $_POST['email'];
  16. if ($STH->execute()) {
  17. throw new PDOExpenition("Ошибка $email уже используеться.\n");
  18. } else {
  19. $STH = $DHB->prepare("INSERT into students (firstName, lastName, sex, section, email, year, exams, isLocal) values (?, ?, ?, ?, ?, ?, ?, ?)");
  20. $STH->execute($student);
  21. }
  22. }
  23. catch (PDOExpenition $e) {
  24.  
  25. }
  26. ?>
Runtime error #stdin #stdout #stderr 0.01s 20568KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Fatal error:  Uncaught exception 'PDOException' with message 'could not find driver' in /home/hrCBlJ/prog.php:14
Stack trace:
#0 /home/hrCBlJ/prog.php(14): PDO->__construct('mysql:host = lo...', 'root', '')
#1 {main}
  thrown in /home/hrCBlJ/prog.php on line 14