私はphpスクリプトにリダイレクトするログインフォームを持っており、ユーザーが登録されているかどうかをデータベースにチェックインします。私がやりたいのは、FirefoxまたはChromeにユーザー名とパスワードを覚えてもらいたいということです。他のページ。
これが私のコードです:
<form id="loginForm" action="../php/login.php" method="post">
<table>
<tr>
<td><label for="user">Username :</label></td>
<td><input name="user" id="user" type="text" /></td>
</tr>
<tr>
<td><label for="password">Password :</label></td>
<td><input name="password" id="password" type="password" /></td>
</tr>
<tr>
<td></td>
<td id="subCont"><input id="submit" type="submit" value="Login"></td>
</tr>
</table>
</form>
そして、jQueryAjaxメソッドですべての情報を処理します
var form = $('#loginForm');
form.on('submit',function(e){
e.preventDefault();
$this = $(this);
$.ajax({
type : 'post',
url : 'php/login.php',
data : $this.serialize(),
dataType : 'json',
success : function(r){
},
error : function(r){
window.alert(r.Message);
}
});
});