function AddToUsers($email, $level) { $resp = "-1"; try { $query = "insert into User(UserEmail, UserLevel) values('{$email}', '{$level}')"; $rs = mysql_query($query); if (!$rs) { $resp = "-1"; } else { $resp = "1"; SendNewUserMail($email); // to send the mail to the user. } return $resp; } catch (Exception $e) { $resp = "-1"; return $resp; } }
function AddUser($organ, $course, $email, $level) { $resp = "-1"; $userAdd = "-1"; $userTable = "-1"; try { if ($level == "B") { // for adding the director. $userAdd = AddToUserTable($email, $level); $userTable = AddToDirectorTable($organ, $email, "Director"); } else { if ($level == "C") { $userAdd = AddToUserTable($email, $level); $userTable = AddToMentorTable($organ, $course, $email, "Mentor"); } else { if ($level == "D") { $userAdd = AddToUserTable($email, $level); $userTable = AddToMenteeTable($organ, $course, $email, "Mentee"); } else { $resp = "-1"; } } } if ($userAdd == "1" && $userTable == "1") { // successful insertions. SendNewUserMail($email); $resp = "1"; } else { $resp = "-1"; } echo $resp; } catch (Exception $e) { $resp = "-1"; echo $resp; } }