selectdata.php*
从php中选择数据的代码
<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=utf-8");
$response = array();
$link = mysqli_connect("localhost", "root", "", "chatapp");
$json = json_decode(file_get_contents("php://input"), true);
$Email = $json['Email'];
$Sql = "SELECT Name, Email, DOB, Password, ConfirmPassword, registered_time FROM user_register WHERE Email = '$Email'";
$result = mysqli_query($link, $Sql);
while($row = mysqli_fetch_assoc($result)){
$response[] = $row;
}
echo json_encode($response);
?>
profiletemplate.html
这是显示输出的代码。
<div id="home" class="container tab-pane active"><br>
<h3>Your Details</h3>
<div class="table-reponsive">
<table class="table">
<div class="form-field-group">
<form name="update" ng-submit="Update()" novalidate>
<p>{{ success }}</p>
<p>{{ error }}</p>
<tbody ng-repeat="results in namess">
<tr>
<th>Name</th>
<td><input type="text" value="{{ results.Name }}" class="form-field" ng-model="results.Name"></td>
</tr>
<tr>
<th>Email</th>
<td><input type="email" value="{{ results.Email }}" class="form-field" ng-model="results.Email"></td>
</tr>
<tr>
<th>DOB</th>
<td><input type="date" value="{{ results.DOB }}" class="form-field" ng-model="results.DOB"></td>
</tr>
<tr>
<th>Password</th>
<td><input type="password" value="{{ results.Password }}" class="form-field" ng-model="results.Password"></td>
</tr>
<tr>
<th>Registered Time</th>
<td>{{ results.registered_time }}</td>
</tr>
<tr>
<td><input type="submit" name="update" class="darkblue-button" value="Update"></td>
</tr>
</tbody>
</form>
</div>
</table>
</div>
</div>
controller.js
这是从中选择并更新数据的代码
chat.controller("profileController", function($scope, $http){
//displayes the username in page
$scope.displayName = localStorage.getItem("Name");
var $Email = localStorage.getItem("Email");
//console.log($Email);
//selects the data according to user
$http.post("selectdata.php",{
'Email': $Email
})
//displays the selected data
.then(function(response){
$scope.namess = response.data;
});
//updates the data according to user
$scope.Update = function(){
$http.post("update.php", {
'Name': $scope.Name,
'Email': $scope.Email,
'DOB': $scope.DOB,
'Password': $scope.Password
})
.then(function(response){
$scope.success = "updated successfully";
}, function(){
$scope.error = "not updated";
});
}
});
错误
Error: [ngModel:datefmt] http://errors.angularjs.org/1.8.2/ngModel/datefmt?p0=2000-11-07
at angular.js:99
at Array.<anonymous> (angular.js:26870)
at Object.$$format (angular.js:31244)
at Object.$processModelValue (angular.js:31224)
at Object.$$setModelValue (angular.js:31256)
at angular.js:31295
at m.$digest (angular.js:19262)
at m.$apply (angular.js:19630)
at k (angular.js:13473)
at v (angular.js:13730)
警告:指定的值“{results.dob}}”不符合所需格式“yyyy-mm-dd”。输入type=“date”格式应为yyyy mm dd如何更改。
暂无答案!
目前还没有任何答案,快来回答吧!