I'm trying to pass 3 variables to another script in my scripts folder to query the db.
EDIT: it refreshes to this page
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
My scripts/changepassword.php:
if (isset($_POST['Username']) && isset($_POST['Password'])&& isset($_POST['Code'])) {
}
The problem is that this just refreshes the current page. It doesn't process the request.