We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    I've never tried to get data from the Login form with JQery, so I'm afraid I don't know. It should be pretty basic JQuery, though -- it's just grabbing the field content by ID.
      Did I help you? Buy me a beer
      Get my Book: MODX:The Official Guide
      MODX info for everyone: http://bobsguides.com/modx.html
      My MODX Extras
      Bob's Guides is now hosted at A2 MODX Hosting
      • 42082
      • 72 Posts
      Thank you for your quick replies, I was meaning how would i get blend jquery with the php code you just showed me? Like this... The user types in there username and password sends the form. I know i can use jquery to get the username and password but i still have no idea on how i would test the username and password that i have with the jquery to see if it is an actual user account.See my problem? I would have to use some kind of php code i assume to test the username and password against those in the database. Am I right? and if so could you possibly point me in the right direction on how to accomplish this.

      Thanks a ton you have really helped me
      P.S. Sorry for all the hassle i must be giving you.
      modxnooby
        • 3749
        • 24,544 Posts
        There's really no way to "blend" JavaScript and PHP code. The PHP code is running on the server and the JS code is running on the client (i.e., in the browser). Neither one is away of the other one's code directly. That's the point of Ajax, which allows you to send message back and forth between the client and the server without reloading the page.

        In your case, you'd probably want to send the username and password in your Ajax call. The PHP code on the page that's the target of the Ajax call can get them from the $_POST array, test them to see if the user is legit, and return a message telling the JS code whether the user is OK.

        This raises all kinds of serious security problems, BTW, because anyone can visit your login page and view the JavaScript code in action. They can also replace the JS code with their own, and if they do it right, the JS will consider them to be logged in (though the server won't). There is also the potential for a "man in the middle" attack where the attacker spoofs your web page with slightly modified JavaScript and captures the username and password of everyone who logs in.
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 42082
          • 72 Posts
          So I am really confused...Are you saying yes using ajax and login can be done but it is a security risk? I am really at a loss.
          • discuss.answer
            • 3749
            • 24,544 Posts
            Yes, that's exactly what I'm saying. It can be done, but using Ajax creates security issues. Login code also creates security issues. The combination creates more serious security issues.
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting