我正在尝试将 3 个变量传递给我的脚本文件夹中的另一个脚本来查询数据库。
编辑:它刷新到这个页面
http://localhost:8080/procity/changepassword.php?username=asdf&password=a&confirm=a&code=bba7886bec2591db69c58dd315144114
JavaScript
function resetPassword() {
var user = document.getElementById('username').value;
var password = document.getElementById('password').value;
var conf = document.getElementById('confirm').value;
var code = document.getElementById('code').value;
if (code.length == 0 || password.length == 0 ||
user.length == 0 || conf.length == 0) {
alert("Entries empty");
} else if (password != conf) {
alert("Passwords don't match");
} else {
$.ajax({
type: "POST",
url: "scripts/changepassword.php",
data: {Username: user, Password: password, Code: code},
dataType: "json",
success: function(data) { alert("success"); }
});
}
}
HTML
<form>
<input id="username" placeholder="Username" name="username" type="text" />
<input id="password" placeholder="Password" name="password" type="password" />
<input id="confirm" placeholder="Confirm Password" name="confirm" type="password" />
<input id="code" placeholder="Code" name="code" type="text" />
<div class="registrationFormAlert" id="incorrectEntry"></div>
<p> </p>
<input class="btn" id="signinbut" onclick="resetPassword()" value="Reset" type="submit" style="width:28%;" />
</form></div>
PHP
我的脚本/changepassword.php:
if (isset($_POST['Username']) && isset($_POST['Password'])&& isset($_POST['Code'])) {
}
问题是这只是刷新了当前页面。它不处理请求。