Here is the HTML code snippet for users to input their email address and student ID:
<div id="statusScope" class="pos-rel" style="margin:0 auto 50px;" ng-controller="statusController">
<form class="form-inline text-center" action="">
<div class="form-group">
<label for="email">Email address:</label>
<input type="email" class="form-control" id="email" ng-model="email">
</div>
<div class="form-group">
<label for="sID">Student ID:</label>
<input type="text" class="form-control" id="sID" ng-model="sID">
</div>
<br/>
<br/>
<button type="button" class="btn btn-primary" ng-click="emailCheck()">E-mail Check</button>
</form>
<div class="alert alert-success" ng-if="msg.success">{{msg.success}}</div>
<div class="alert alert-danger" ng-if="msg.noStudent">{{msg.noStudent}}</div>
<br>
</div>
The following code segment validates the entered email address and student ID, returning success if they match or "incorrect details" if they do not:
$scope.emailCheck = function() {
var _to = $scope.email,
_studentID = $scope.sID,
_subject = "System Notify.",
var all = [].concat($scope.users.cis300, $scope.users.cis400, $scope.users.cis500);
var student = all.filter(function(item) {
return item.email == _to && item.studentid == _studentID;
});
if(student && student.length) {
var _file1 = student[0].tfile;
var _file2 = student[0].tfile1;
var _file3 = student[0].tfile2;
_msg = "Hello, "+student[0].firstname+" "+student[0].middlename+". "+student[0].lastname+". \r\n"+"Your status is " + student[0].status + ". \r\n",
$.post('php/mail.php',
JSON.stringify({
'to': _to,
'subject': _subject,
'file1': _file1,
'file2': _file2,
'file3': _file3,
'msg': _msg
}),
function(response, status) {
$scope.msg.success = "Success! Check your Email";
});
} else {
$scope.msg.noStudent = "Email or Student ID is incorrect.";
}
While incorrect information triggers the "Student ID or Email is incorrect" message instantly, correct input results in an email sent to the user. However, the success alert only appears after making changes in the fields.