I've been trying to figure out why my login page isn't working so I've been watching it in the debugger (MS Edge on Win10). Come to find out the server side portion correctly returns true or false. But when I step through the code, I see it output my test statement to the add_err div. Then it loops through AGAIN and hides the div again.
This is what my javascript code looks like. The php page returns 'true' if I entered the correct login info and 'false' if not.
<?php $prefix = isset($_GET['mode']) ? $_GET['mode'] : "Desktop"; ?>
$(document).ready(function(){
$("#add_err").css('display', 'none', 'important');
$("#Login").submit(function(){
var formData = $( this ).serialize();
$.post("login.inc.php", formData, function(data){
//$("#add_err").html(data);
$("#add_err").css('display', 'inline', 'important');
if(data == 'false'){
$("#add_err").html("Username & Password combination does not match our records.");
}else{
$("#add_err").css('display', 'inline', 'important');
$("#add_err").html("ok");
// $("#MainContent").load("./<?php echo $prefix . 'Home.html'; ?>");
}
});//post
});//submit
});//ready
This is the form portion of my login page.
<script type="text/javascript" src="js/login_js.inc.php?mode=<?php echo $prefix; ?>"></script>
<form id="Login" method="post" action="./">
<table>
<tr><td colspan="2"><div class="err" id="add_err"></div></td></tr>
<tr><td>Username: </td><td><input type="text" name="user" id="user" required></td></tr>
<tr><td>Password: </td><td><input type="password" name="pass" id="pass" required></td></tr>
<tr><td>Automatic Login: </td><td><input type="checkbox" name="autoLogin"></td></tr>
<tr><td>Allow Offline Mode: </td><td><input type="checkbox" name="allowOffline"<?php if(isset($_COOKIE['allowOffline'])){echo " checked";}?>></td></tr>
<tr><td colspan = 2 align="center"><span style="font-size:small;">Note: Do not set either option on a shared device.</span></td></tr>
<tr><td colspan = 2 align="center"><input type="Submit" name="loginSubmit" id="loginSubmit" value="Submit"> <input type="reset"></td></tr>
</table>
</form>
Can anyone offer any suggestions? Ultimately once I know this is working, I want the form to be replaced by the contents of "DesktopHome.html".