Archive for July 21st, 2010

July 21st, 2010

Ajax-based Login Control Without Any Standard Database

Introduction: In this tutorial I am going to base a simple login control on AJAX. All login control needs a database that stores all user profiles, such as passwords. Server-side script uses the database from user given string matches to compare and shows errors or redirects to relevant pages, etc. However, the proposed technique is no standard database like Access, SQL is required, etc. It only takes a native XML Flat / text database, to implement the minimum complexity in practice.

I was looking for this kind of simple log-in approach and, finally, came the thought, however, the Asynchronous JavaScript and XML technology (in short AJAX) . On many occasions, the establishment of an external database is cumbersome and not worthy in terms of minimal customs. The proposed Login control, but will help you all the load, and compatibility issues to be removed. To be clear, conventional and standard database application, a database server, the authentication and authorization required before the creation of a database, database string to be used in the script, the platform-specific and is awkward for me always. To get rid of all the costs and efforts, the proposed approach uses a simple flat database tables and read the database with (AJAX) to control a pretty login.

Keep reading

!

Big Picture: The following figure shows the AJAX-based login control display. User can enter his password into the text field. For simplicity, I have all the names of the States United States as passwords. If the user specified string games with one of the passwords, make the “search” button appears. In other words, the user’s desired page by clicking on this button will be forwarded.

In case the user’s input string is not a pre-fix match of the passwords, the color of the text box will automatically be yellow. It tells the user not in this direction and try to delete some of the characters try again.

Necessary files: we need four files for this login control

i) script. html

ii) script. css

iii) script. js

iv) script. xml

the HTML and CSS file corresponds to the content and design to show, above all, at various components. Note that the “query” Submit “button is kept hidden from visibility. It will only be displayed if the user string with one of the passwords stored in the XML file matches.

JavaScript AJAX file controls the connectivity and read the password on the fly. As soon as user presses a letter on the text field, the function works for any game or disproportionate to review and act accordingly.

hold a single character fills the function of all passwords in a hidden “popoups” (which is actually not a pop!) HTML component. The function is true then the string with the user string. If the pop-ups component is empty, there is the user string is not a prefix of one of the passwords and makes the text box yellow.

present but in the event of agreement between the two strings, the button will be displayed. User can now click directly requested by his side.

/ / ————— ———- — script. html —————————————-



;

Auto-Fill States </ title> </ p> </p> <p> <link rel = "stylesheet" rev = "stylesheet" rel = "nofollow" onclick = "javascript: pageTracker. _trackPageview ('/ outgoing / article_exit_link');" href = "script. <css" /> </ p> br /> <br /> <p> <script type="text/javascript"> src = "script. js"; </ p> </p> <p> </ script> </ p> </p> <p> </ head> </ p> <br /> <br / > <br <body> </ p> </p> <p> <form action="#"> </ p> <br /> ; <br /> <p> Please enter your password: </ p> </p> <p> <input type = "text" id = " search field "autocomplete =" off "/> </ strong> </ p> </p> <p> </ p> <br /> < ; div id = "popups"> </ div> </ p> </p> <p> <strong><br /> <input type = "submit" id = "submitme" style = "visibility: hidden"> </ strong> </ p> <br /> <br / <p> </ form> </ p> <br /> < , br /> <p> </ body> </ p> </p> <p> </ html> </ p> <br /> ; <br /> <p> / / ---------------------------- script. css ----------------------------------------</ p> <br / > <br /> <br popups # (</ p> </p> <p> position: absolute; </ p> </p> <p> visibility: hidden; </ strong> </ p> </p> <p>) </ p> <br / > <br /> <p> # search box. Error (</ p> </p> <p> background-color: # FC0; </ strong> </ p> <br /> <br / <p>) </ p> </p> <p> / / ------------------- --------- script. js ----------------------------------------</ p> <br / > <br /> <br window. onload = initAll; </ p> </p> <p> XHR var = false; </ p> </p> <p> ; state var array = new Array ();</ p> </p> <p> pass var array = new Array ();</ p> </p> <p> initAll function () (</ p> </p> <p> <br document. getElementById ("Search Box"). onkeyup = searchSuggest; < / p> </p> <p> if (window. XMLHttpRequest) </ strong> (</ p> </p> <p> < p> XHR = new XMLHttpRequest ();</ p> </p> <p>) </ p> </p> <p> < p> else (</ p> </p> <p> if (ActiveXObject window.) (</ p> </p> <p> < <p> try (</ p> </p> <p> XHR = new ActiveXObject ("Microsoft. XMLHTTP ");</ p> <br /> , br /> <p>) </ p> </p> <p> catch (e) () </ p> <br /> < br /> <br) </ p> </p> <p>) </ p> </p> <p> if (XHR) (</ p> </p> <p> XHR. onreadystatechange = setStatesArray; </ p> </p> <p> XHR. open ("GET", "United States. xml", true); </ strong> </ p> </p> <p> XHR. send (null ) </ p> </p> <p>) </ p> </p> <p> else (</ p> </p> <p> alert ("Sorry, but I could not create an XMLHttpRequest ");</ p> </p> <p>) </ a> </p> <p>) </ a> </p> <p> function setStatesArray () (</ p> </p> <p> if (xhr. readyState == 4) (</ strong> </ p> </p> <p> if (status == xhr. 200) </ strong> (</ p> </p> <p> if (xhr. responseXML) (</ p> </p> <p> var XHR = Allstate. responseXML. getElementsByTagName ("item ");</ p> <br /> < , br /> <p> for (var i = 0; i <Allstate. length; i + +) (</ p> </p> <p> state array [i] = Allstate [i]. getElementsByTagName ("label") [0]. firstChild; </ p> </p> <p>) </ p> < br /> <br /> <p>) </ p> </p> <p>) </ p> <br /> < br /> <p> else (</ p> </p> <p> alert ("There was a problem with the request" + XHR. status); < / p> </p> <p>) </ p> </p> <p>) </ p> </p> <p>) </ p searchSuggest> </p> <p> function () (</ p> <br / > <br /> <p> var str = document. getElementById ("Search Box"). value; </ p> </p> <p> document. getElementById ("Search Box"). className = "";</ p> </p> <p> if (str! = "") (</ p> <br / > <br /> <p> document. getElementById ("popup"). "";</ innerHTML = p> </p> <p> var flag = 0; </ p> </p> <p> for (var i = 0; i <state array. length; i + +) (</ strong> </ p> </p> <p> thisState var state = array [i] nodeValue.; </ strong> </ p> </p> <p> </ strong> </ p> </p> <p> if (str = = thisState) (</ strong> </ <p> br /> <br /> <p> flag = 1; </ strong> </ p> </p> <p> strong>) </ strong> </ p> </p> <p> </ p> <br /> if (thisState. toLowerCase (). indexOf (str toLowerCase ()) = = 0) (</ p> </p> <p> tempDiv var = document. createElement ("div ");</ p> </p> <p> ; <p> tempDiv. innerHTML = thisState; </ p> </p> <p> / / tempDiv. onclick = makeChoice; </ p> <br /> ; <br /> <p> tempDiv. className = "proposals"; </ p> </p> <p> document. getElementById ("popup"). appendChild (tempDiv) </ p> </p> <p>) </ p> </p> <p> < , br /> </ p> <br /> <br) </ p> </p> <p> foundCt var = document. getElementById ("Popups "). childNodes. length; </ p> </p> <p> if (foundCt == 0) (</ p> </p> <p> document. getElementById ("Search Box"). className = "error"; </ p> </p> <p> document. getElementById ("submitme" ). style. visibility = "hidden"; </ p> </p> <p>) </ p> </p> <p> < , p> if (foundCt> 0) (</ strong> </ p> </p> <p> </ strong> </ p> <br / > <br /> <p> if (flag == 1) (</ strong> </ p> </p> <p> </ strong> , </ p> </p> <p> document. getElementById ("submitme"). style. visibility = "visible"; </ strong> </ p> < , br /> <br /> <p> </ strong> </ p> </p> <p>) </ strong> </ p> </p> <p> </ p> <br />) </ p> </p> <p>) < / p> </p> <p>) </ p> </p> <p> < p> Javascript: <strong> window. XMLHttpRequest object </ strong> <strong> AJAX </ strong> <strong> begins connectivity. The client reads from an XML file, parse the necessary data and use this information in the client side. </ Strong> </ p> </p> <p> then the value against the specified string is compared. If it matches with the stored passwords, provide the 'key' appears (case B in the figure). However, any discrepancy between the two strings and hold the "Send" button hidden from view. The discrepancy is represented by the yellow color (at C in the figure). Note that in C means that it can not prefix all stored passwords of user-specified string. Therefore, users should delete and re-enter. </ P> </p> <p> </ p> </p> <p> / / -------------- -------------- states. xml (passwords) ----------------------------------------</ p> < , br /> <br /> <? xml version = "1 0 "?></ p> </p> <p> <choice xml:lang="en"> </ p> < , br /> <br /> <p> <item> </ p> </p> <p> <label> Alabama </ label> </ p> </p> <p> <value> AL </ value> </ p> </p> <p> < / item> </ p> </p> <p> <item> </ p> </p> <p> < ; label> Alaska </ label> </ p> </p> <p> <value> AK, / value> </ p> <br / > <br /> <p> </ item> </ p> </p> <p> <item> </ p> </p> <p> <label> Arizona </ label> </ p> </p> <p> <value> AZ </ value> </ p> </p> <p> <br </ item> </ p> </p> <p> ... ... ... ... ... ... ... ... ... ... ... ... .... </ P> </p> <p> ... ... ... ... ... ... ... ... ... ... ... ... .... . <p> </ P> </p> <p> </ choices> </ p> </p> <p> Conclusion: advantage of this code that you do not need to use any type of standard databases (Access, SQL database, etc). Just put these four files change on your server, or populate the XML script with your passwords (customers) and run the HTML. Now the server (eg, <a rel="nofollow" http://localhost onclick="javascript:pageTracker. _trackPageview('/outgoing/article_exit_link');" href="http://localhost/path"> / call path </ a >..). His work, right? You see all the complexity in terms of standard database connection in the server-side script is not required. In many cases this simple script to setup your burden and external database and SQL code will be removed in your script. </ P> </p> <p> simpler Happy programming! </ P> </p> <p> Manzur Ashraf </ p> </p> <p> <a rel = "nofollow" onclick = "javascript: pageTracker. _trackPageview ('/ outgoing / article_exit_link');" href = "http://www. sacar. com. au /"> www. sacar. com. Au </ a> </ p> </p> <div style="margin:5px;padding:5px;border:1px solid #c1c1c1;font-size: 10px;"></ P> <br Manzur Ashraf is with Adtran Ltd, Adelaide, Australia working as a developer and SEO Analyst. It can be at manzur_bd reasched @ yahoo. com manzurashraf, @ adtransgroup. com. au. </ P></div> </div> <div class="icons-readmore clearingfix"> <div class="icons"> <a href="http://technorati.com/faves?add=http://www.complinenyc.org/?p=143" title="Bookmark Ajax-based Login Control Without Any Standard Database on Technorati" class="one"></a> <a href="http://del.icio.us/post?url=http://www.complinenyc.org/?p=143&title=Ajax-based Login Control Without Any Standard Database" title="Bookmark Ajax-based Login Control Without Any Standard Database on Delicious" class="two"></a> <a href="http://digg.com/submit?phase=2&url=http://www.complinenyc.org/?p=143" title="Digg Ajax-based Login Control Without Any Standard Database" class="three"></a> <a href="http://reddit.com/submit?url=http://www.complinenyc.org/?p=143&title=Ajax-based Login Control Without Any Standard Database" title="Bookmark Ajax-based Login Control Without Any Standard Database on Reddit" class="four"></a> <a href="http://www.stumbleupon.com/submit?url=http://www.complinenyc.org/?p=143" title="Bookmark Ajax-based Login Control Without Any Standard Database on StumbleUpon" class="five"></a> </div> <div class="readmore"><a href="http://www.complinenyc.org/?p=143" class="more" title="Read more of Ajax-based Login Control Without Any Standard Database">Read More</a></div> </div> </div> <div class="navigation"> <div class="alignleft"></div> <div class="alignright"></div> </div> </div> </div> </div> </div> </div> </div> </div> </div> <!-- Main Body End --> </div> </div> </div> </div> </div> </div> </div> </div> </div> <!-- wpr End --> </div> <div id="footer"> <div class="wpr floatholder"> <br clear="all" /> </div> <div id="copyright"> <div class="wpr floatholder"> Copyright © 2010 <a href="http://www.complinenyc.org" title="Web Development | Web Design">Web Development | Web Design</a> - .<br/> Visit www.complinenyc.org for the latest news on <a href="http://www.complinenyc.org/">web hosting</a> and <a href="http://www.complinenyc.org/">cms review</a>. </div> <!-- Footer wpr End --> </div> </div> <!-- Footer End --> </body> </html> <!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/ Served from: www.complinenyc.org @ 2010-09-05 14:42:48 -->