My Ionic app Code is following:
<label class="item item-input item-floating-label light">
<span class="input-label">Date</span>
<input type="date" placeholder="Date" ng-model="data.date" style="color: white;">
</label>
<div class="list card" style="background:#3CB371;" ng-repeat="student in students">
<ion-checkbox class="checkbox-balanced" ng-model="data.reg_no" ng-checked="data.reg_no" style="color: white;">{{student.reg_no}}</ion-checkbox>
</div>
//sends the data to server Add
app.js Code is following:
.controller('TakeAttendanceCtrl', function($scope, $http, ionicMaterialInk){
$scope.add = function(data) {
$http({
method: 'post',
url: host + 'api.php?take_attendance',
params: data
})
.then(
function(suc) {
if (confirm("Attendance updated.")) {
window.location.href = "home.html";
} else {
window.location.reload();
}
},
function(err) {});
}
})
and my server side code is following: (api.php)
include "library.php";
if(isset($take_attendance))
{
insert("attendance","'','$date', '$reg_no'");
}
and the library.php file is this:
header("Access-Control-Allow-Origin:*");
extract($_REQUEST);
mysql_connect("localhost","root","");
mysql_select_db("sis");
function insert($table,$values)
{
mysql_query("insert into $table values($values)");
// echo "insert into $table values($values)";
}