Jump to content

doni49

Members
  • Posts

    515
  • Joined

  • Last visited

Everything posted by doni49

  1. I'm working to develop a web app using jQuery and AJAX on the client side and PHP on the server side. The app processes the login as an AJAX call (using jQuery code). If after logging in the user refreshes the page, they're presented with the login page again. Prior to using AJAX, I would set a SESSION variable upon login. And upon refresh, the PHP script would see that the SESSION variable is set and not display the login page again. How can I make the calling page recognize SESSION variables set by php scripts called via AJAX?
  2. I've read a lot of examples of how to do this but this is the first time I've seen this PreventDefault method. Now that I added that, the login actually shows the correct info. As to the question about reading the whole reply, yes I did read the entire thing but I didn't understand what this method was supposed to do -- I thought maybe it was somehow related to the issue of possible code injection. I greatly appreciate the assistance.
  3. Thanks good point about the get. This project is in the beginning stages and (hopefully at least) I think I would've caught that down the road. I'll address that tonight. But that still doesn't do any good for the problem I actually asked about. Why does it set the add_err div to show the text and then run through and disable it again?
  4. 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".
  5. One more things to try: before the first <?php place just the word STARTING. Then at the very end of the file (after the last ?>, place the word ENDING. Load the file in your browser. Do you see STARTING and ENDING? If not your server isn't sending the file to the browser. If you do see them, you must have some kind do of php issue.
  6. That's not actually correct. The following was copied from the link below. When converting to boolean, the following values are considered FALSE: ◦ the boolean FALSE itself ◦ the integer 0 (zero) ◦ the float 0.0 (zero) ◦ the empty string, and the string "0" ◦ an array with zero elements ◦ an object with zero member variables (PHP 4 only) ◦ the special type NULL (including unset variables) ◦ SimpleXML objects created from empty tags Every other value is considered TRUE (including any resource). http://php.net/manual/en/language.types.boolean.php#language.types.boolean.casting
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.