<?php
$student = array('DatafirstName', 'DatalastName', 'Datasex', 'Datasection', 'Dataemail', 'Datayear', 'Dataexams', 'DataisLocal'); $example = array('firstName', 'lastName', 'sex', 'section', 'email', 'year', 'exams', 'isLocal');
//foreach ($example as $field) {
// $student[] = $_POST[$field];
//}
try {
$DHB = new PDO('mysql:host = localhost;dbname = sat', 'root', '');
$STH = $DHB->prepare("SELECT email FROM students WHERE email = ?");
$STH->bindparam(1, $email);
$email = $_POST['email'];
if ($STH->execute()) {
throw new PDOExpenition("Ошибка $email уже используеться.\n");
} else {
$STH = $DHB->prepare("INSERT into students (firstName, lastName, sex, section, email, year, exams, isLocal) values (?, ?, ?, ?, ?, ?, ?, ?)");
$STH->execute($student);
}
}
catch (PDOExpenition $e) {
}
?>
PD9waHAKCm1iX2ludGVybmFsX2VuY29kaW5nKCd1dGYtOCcpOwplcnJvcl9yZXBvcnRpbmcoLTEpOwoKJHN0dWRlbnQgPSBhcnJheSgnRGF0YWZpcnN0TmFtZScsICdEYXRhbGFzdE5hbWUnLCAnRGF0YXNleCcsICdEYXRhc2VjdGlvbicsICdEYXRhZW1haWwnLCAnRGF0YXllYXInLCAnRGF0YWV4YW1zJywgJ0RhdGFpc0xvY2FsJyk7CiRleGFtcGxlID0gYXJyYXkoJ2ZpcnN0TmFtZScsICdsYXN0TmFtZScsICdzZXgnLCAnc2VjdGlvbicsICdlbWFpbCcsICd5ZWFyJywgJ2V4YW1zJywgJ2lzTG9jYWwnKTsKCi8vZm9yZWFjaCAoJGV4YW1wbGUgYXMgJGZpZWxkKSB7Ci8vCSRzdHVkZW50W10gPSAkX1BPU1RbJGZpZWxkXTsKLy99Cgp0cnkgewoJJERIQiA9IG5ldyBQRE8oJ215c3FsOmhvc3QgPSBsb2NhbGhvc3Q7ZGJuYW1lID0gc2F0JywgJ3Jvb3QnLCAnJyk7CgkkU1RIID0gJERIQi0+cHJlcGFyZSgiU0VMRUNUIGVtYWlsIEZST00gc3R1ZGVudHMgV0hFUkUgZW1haWw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