/* ----- VALIDATION */ if (sizeof($error) == 0) { // No validation errors. Can continue. $user = array(); $user['username'] = $db->escape($username); $user['email'] = $db->escape($email); $user['password'] = sha1($password); $user['first_name'] = $db->escape($name); $user['gender'] = $gender == 'male' ? 1 : 0; $user['institute'] = $db->escape($institute); $user['location'] = $db->escape($location); $user['registered_in'] = date("Y-m-d H:i:s", time()); $user['verified'] = 0; // Register the user $registrar = new Registrar($db); $user_id = $registrar->registerUser($user); if ($user_id) { // Registration successfull - Send the email verification link if ($registrar->sendVerificationEmail($user_id, $email)) { $result = array('success' => true); } else { $result = array('success' => false, 'error' => 'Unexpected error!'); } header('Content-Type: application/json'); echo json_encode($result); exit; } } else { $result = array('success' => false, 'error' => implode("<br/>", $error)); header('Content-Type: application/json'); echo json_encode($result);