Creating Ajax Login Form

Ajax Login Form

What Is Ajax Login Form

enable to make easy and fast progress log-in form to verification username and password without refresh page to check valid account and lets to redirect to user page!

  • Run Tested in IE6, FF3, Opera9 and i think should be worked in other modern browsers as well
  • easy to used with any method login verification
  • Automattic redirection could be done within the javascript config
  • Verification account without refresh page
  • Message Error login

How To Crating Ajax Login Form
First, let’s start to creating the login form page. I will explain you the code this code will be check login action so you can change the verification method using database mysql or something like that.


this php code to check verification username and password write in ouf.php file name :

  1. $action=trim($HTTP_GET_VARS['action']);
  2. switch($action):
  3.         case ‘login’:
  4.                 $good_email="zmoerf@ajax-tutorial.net";
  5.                 $good_pass="ajax";
  6.                 $sub = trim($_POST['sub']);
  7.                 $email = trim($_POST['email']);
  8.                 $password =trim($_POST['password']);
  9.                 $sep=’,';
  10.                 sleep(2); # simulating
  11.                 $msg="Email and password do not match";
  12.                 if ( $password == $good_pass ){
  13.                    # REGISTER SESSION HERE
  14.                    print ’success,welcome.html,lolllll’;
  15.                 }
  16.                 else{
  17.                    print ‘error’.$sep.$msg;
  18.                 }
  19. //              print ’success,index.php’;
  20.         break;
  21.         default:
  22.                 print ‘error,going somewhere ?’;
  23. endswitch;
  24. #check if the mail is valid
  25. function fun_isemail($strng){
  26.  return preg_match(’/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/i’,$strng);
  27. }

 

and after you crated verificatioin code now you can write html code to make login form but you must call javascript ajax to progress verification without refresh.

this code to call javascript ajax put on header in login.html file:

  1. <script type="text/javascript" src="js/_ajax.new.js?<?=rand()?>"></script>
  2. <script type="text/javascript" src="js/_formdata2querystring.js"></script>
  3. <script type="text/javascript" src="js/_applogin.js?<?=rand()?>"></script>
  4.   <link rel="stylesheet" href="css/style.css?<?=rand()?>" type="text/css">

 this html code make login form put div id="logindiv" betwen form in login.html file :

  1. <div id="logindiv">
  2.       <form id="loginForm" method="POST" action="index.php">
  3.         <div id="promptDiv" class="basePrompt">
  4.           <span id="msg1"></span>
  5.           <span id="msg2"></span>
  6.         </div>
  7.           <div class="fieldTitle">Email:</div>
  8.           <div class="fieldEntry">
  9.             <input id="email" name="email" type="text" value="" alt="Email should be email@gospam.biz" title="Email should be email@gospam.biz">
  10.           </div>
  11.           <div class="fieldTitle">Password:</div>
  12.           <div class="fieldEntry">
  13.             <input id="password" name="password" type="password" value="" alt="Password should be iwannalogin" title="Password should be iwannalogin">
  14.           </div>
  15.         <div id="buttonDiv">
  16.           <input type="submit" id="submitButton" name="submitButton" value="Submit"/>
  17.         </div>
  18.                 <small>
  19.                 <u>Hint:</u><br />
  20.                 Ajax Login Demo
  21.                 </small>
  22.       </form>
  23.     </div>

Demo Ajax Login Form Not Aviable
Download Ajax Login Form Here

Posted by admin   @   19 October 2009
Tags : , ,

Related Posts

0 Comments

No comments yet. Be the first to leave a comment !
Leave a Comment

Name

Email

Website

Previous Post
« Ajax Form Validation Tutorial
Next Post
Top Ajax CMS (Content Management System) »
Powered by Wordpress   |   Lunated designed by ZenVerse
Top Footer