Home Top Projects Tutorials Articles Submit Project
 
  • .NET Frameworks
  • Java Frameworks
  • PHP Frameworks
  • Ruby Frameworks
  • Other Frameworks
  • Cool AJAX sites
  • Ajax Resources
  • Ajax Tools
  • JavaScript frameworks
 
     
    • Creating an Ajax Autocompletion Textfield with Dynamic Faces
    • New Release - Ajax Calendar Starter-Kit
    • Enunciate your web APIs
    • JavaScript as a Functional Language
    • Ajax username availability checking
    • jQuery AJAX Reference
    • To ExtPHP, or to PHP-Ext?
    • Wcf Return Json
    • jQuery XML Parser with Sorting and Filtering
    • AutoCompleter 101
    Home » Tutorials » PHP ajax login form using Jquery

    PHP ajax login form using Jquery

    Because a lot of responses to the previous post php ajax tutorial create ajax based login form using jquery, and asking about some bug fixxing incl IE bugs, i decide to create a new PHP ajax login functionality using Jquery, and here it is…
    Whats new?

        * Completely recoded
        * Tested in IE6, FF3, Opera9 and i think should be worked in other modern browsers as well
        * Easliy switch the data source between database and PHP array
        * Login authentication can be using username or email, or even both of ‘em by changing the config
        * Automattic redirection could be done within the javascript config
        * Redirect target (on success) can be changed in config file
        * Message and Text controled by array variable which could be changed in 1 file

    dependency:

        * Jquery 1.2.3, never tested with the prior version
        * PHP5, If you running prior version then you need to make some changes, probably but not limited at class constructor to make it compatible with your PHP version.

    How to?

        * Switch the data source : Turn the value of USEDB constant in login.config.php into true, and modify the db_config array values as needed, to use array vars turn it false and modify the user_config array values
        * change the authentication method : change the LOGIN_METHOD constant value, possible values:
              o user : match the username and password
              o email : match the user email and password
              o both : match the username or user email and password
        * switch automattic redirection : turn the value of autoRedir var in login.js to true
        * change the redirect target : change the value of SUCCESS_URL constant in login.config.php, for example you need to automatically redirect to user profile, so change it into “index.php?profile=”.$_SESSION['exp_user']['username']
        * change error message and text : change the array values accordingly at login.lang.php

    Notes:

        * Thanks to John resig and the jquery developer team, thanks guys you made my life easier
        * Please do not link to the download file directly, link to this page instead
        * This script is absolutely free, credits nor link is not required but will be great if this site got ‘em

    Demo & Download

        * The demo available here use admin|admin@localhost|123456 as the test account
        * Download the source again please do not link to the file directly, link to this page instead.

    SQL
    view plaincopy to clipboardprint?

       1.CREATE TABLE `tbl_user`
       2.(
       3.`userid` integer (11) NOT NULL AUTO_INCREMENT ,
       4.`username` varchar (50) NOT NULL,
       5.`useremail` varchar (100) NOT NULL,
       6.`userpassword` varchar (50) NOT NULL,
       7.PRIMARY KEY (`userid`)
       8. ) TYPE=MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci;
       9. 
      10.BEGIN;
      11.INSERT INTO `tbl_user` (`userid`, `username`, `useremail`, `userpassword`) VALUES(1, 'admin', 'admin@chazzuka.com', 'e10adc3949ba59abbe56e057f20f883e');
      12.INSERT INTO `tbl_user` (`userid`, `username`, `useremail`, `userpassword`) VALUES(2, 'user', 'user@chazzuka.com', 'e10adc3949ba59abbe56e057f20f883e');
      13.COMMIT; 

    CREATE TABLE `tbl_user`
    (
    `userid` integer (11) NOT NULL AUTO_INCREMENT ,
    `username` varchar (50) NOT NULL,
    `useremail` varchar (100) NOT NULL,
    `userpassword` varchar (50) NOT NULL,
    PRIMARY KEY (`userid`)
    ) TYPE=MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci;

    BEGIN;
    INSERT INTO `tbl_user` (`userid`, `username`, `useremail`, `userpassword`) VALUES(1, 'admin', 'admin@chazzuka.com', 'e10adc3949ba59abbe56e057f20f883e');
    INSERT INTO `tbl_user` (`userid`, `username`, `useremail`, `userpassword`) VALUES(2, 'user', 'user@chazzuka.com', 'e10adc3949ba59abbe56e057f20f883e');
    COMMIT;

    The Jquery file can be downloded at jquery.com If you found something doesnt work as expected just let me know.
    Update

    Bug in google chrome beta which reported by Azo has fixed, the problem is caused by 2 byte chunk data in ajax JSON response which makes the response not valid JSON format, those chunks produced by files which include (required) in login.post.php (”login.lang.php” & “login.class.php”).

    source: chazzuka

    Copyrights Reserved AjaxProjects.com 2006-2013, Powered by Enozom - Mobile Development Company -Privacy Policy