function createStudent($name, $password, $birthdate, $university, $email, $cellphone, $cv, $linkedin) { global $db; $stmt = $db->prepare('INSERT INTO Student (name, password, birthdate, university, email, cellphone, cv, linkedin) VALUES (:name, :securePassword, :birthdate, :university, :email, :cellphone, :cv, :linkedin)'); $securePassword = hash("sha256", $password); $stmt->bindParam(':name', $name, PDO::PARAM_STR); $stmt->bindParam(':securePassword', $securePassword, PDO::PARAM_STR); $stmt->bindParam(':birthdate', $birthdate, PDO::PARAM_STR); $stmt->bindParam(':university', $university, PDO::PARAM_STR); $stmt->bindParam(':email', $email, PDO::PARAM_STR); $stmt->bindParam(':cellphone', $cellphone, PDO::PARAM_INT); $stmt->bindParam(':cv', $cv, PDO::PARAM_STR); $stmt->bindParam(':linkedin', $linkedin, PDO::PARAM_STR); try { $stmt->execute(); return existsStudent($email); } catch (PDOException $e) { return false; } }
<p>Best reagards, </p> <p>The CASE Platform Team</p> </body> </html> '; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'From: case.shareup@gmail.com' . "\r\n" . 'Reply-To: case.shareup@gmail.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); } if (isset($body)) { $json = json_decode($body); $pw = generateRandomString(6); if (existsStudent($json->email)) { $message = array('error' => 'Student already exists'); } else { if (createStudent($json->name, $pw, $json->birthdate, $json->university, $json->email, $json->cellphone, $json->cv, $json->linkedin)) { $student = studentIdByEmail($json->email); $studentID = $student['id']; $message = array('success' => 'Student was successfully created', 'userid' => $studentID); sendWelcomeMail($json->email, $pw); if (isset($json->hasPicture)) { $message = array('success' => 'Student was successfully created and id will be set', 'userid' => $studentID); $_SESSION['id'] = $studentID; $_SESSION['email'] = $json->email; $_SESSION['type'] = "student"; $_SESSION['burner'] = ""; } } else {