jQuery AJAX Tutorial Pt2

Heres Part 2 of the jQuery AJAX login tutorial. If you haven’t already, i suggest you read part 1 located here.

We are going to start writing the PHP code to process the form. This is fairly basic stuff, using $_POST to get the values from the form, then checking them against pre-assigned values, if they match, then echo approved, if they don’t then echo denied.

  1. <?php
  2.  
  3. if($_POST[’submit’]){
  4.  
  5.  
  6. $username = $_POST[‘username’];
  7. $password = $_POST[‘password’];
  8.  
  9. // Here you would put your validation, checking existing database records.
  10.  
  11. if($username == panzer && $password == query7){
  12.  
  13. echo ‘Logged in’;
  14.  
  15. //Insert your cookie setting code here
  16.  
  17. } else {
  18.  
  19. echo ‘Denied’;
  20.  
  21. }
  22.  
  23. } else {
  24.  
  25. echo "Form not submitted";
  26.  
  27. }
  28. ?>

So at the end of this stage, you will have an HTML form set up and this PHP file. You can enter the username Panzer and the password of query7 into the form and it will return Logged in.

Next tutorial, the fun part, the AJAX!

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • StumbleUpon
  • Digg
  • DZone
  • Slashdot
  • Technorati
  • Sphinn
  • del.icio.us
  • Facebook
  • Google
Filed under: Uncategorized, ajax, code, jquery, php, tutorial, , ,

jQuery AJAX Login Series Pt1

Heyo. This is going to be the first of 4 tutorials on making a jQuery powered AJAX login system with a PHP backend. The series of tutorials will go like so.

  1. Plan, code the form (This tutorial)
  2. Code the PHP backend, make it work
  3. Code the AJAX, implement it.
  4. Tidy it up, make it look snazzy

Ok then. So we will have a forum with 2 inputs; username and password. The user will enter the details and we’ll use PHP to authenticate them. If its true, we can set a cookie or echo some text. We will then implement jQuery’s AJAX and make the whole thing seemless. Some nice little fades will be added at the end.

So, the form. Its a plain and simple HTML form. Nothing special about it.

  1. <form method="post">
  2.  
  3. <b>Username:</b><input type="text" name="username">
  4.  
  5. <b>Password:</b><input type="password" name="password">
  6.  
  7.        
  8. <input type="submit" name="login" value="Login">
  9. </form>

Thats all for now. Next lesson we will code the PHP and “make it work“.

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • StumbleUpon
  • Digg
  • DZone
  • Slashdot
  • Technorati
  • Sphinn
  • del.icio.us
  • Facebook
  • Google
Filed under: ajax, jquery, php, tutorial, , , ,

AJAX Series Coming Soon!

Hey guys, just thought i’d post a little interim post (as such). Im in the process of making a 4 part tutorial series on using jQuery’s AJAX. Its a “case study” where i/we will make a basic login form with a PHP backend and then use jQuery to make the login seemless. Eg. you put your username/password in the form and click the login button the page doesn’t reload but it will tell you whether its the correct user/pass , in which case a cookie is set, or if its bad info.

It might take a little while to finish up so i might not be posting much over the next week (sorry) but it will be worth it in the end.

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • StumbleUpon
  • Digg
  • DZone
  • Slashdot
  • Technorati
  • Sphinn
  • del.icio.us
  • Facebook
  • Google
Filed under: query7

Revising the jQuery Drop Down

This post is in reference to the jquery drop down menu tutorial .

Someone emailed me asking if the menu could truely slide in , vertically, not how it is now with the slide on a slight angle ( using jquery’s show / hide ). Its very easy to alter the existing code to make it truely slide.

Instead of using jQuery’s show and hide functions, we just use slideDown and slideUp in replace of them. So the jQuery looks like this..

  1. $(document).ready(function(){
  2.  
  3. $("#drop_down").hide();
  4. $("#drop_down").animate({
  5.  
  6. opacity:0.5
  7.  
  8. });
  9.  
  10.  
  11. $("a:contains(’Google’)").click(function() {
  12. $("#drop_down").slideDown("slow");
  13.  
  14. });
  15.  
  16. $("#drop_down").mouseout(function(){
  17. $(this).slideUp("slow");
  18.  
  19. });
  20. });

Demo file

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • StumbleUpon
  • Digg
  • DZone
  • Slashdot
  • Technorati
  • Sphinn
  • del.icio.us
  • Facebook
  • Google
Filed under: code, jquery, ,

Making a Slide in Menu using jQuery (Video tutorial)

This video tutorial shows how to make a basic slide in/drop down menu using jQuery. The menu itself stylishly slides in and has transparencies so you can view data behind it.

Sorry for the low sound, i was trying something different with my microphone.

Demo File

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • StumbleUpon
  • Digg
  • DZone
  • Slashdot
  • Technorati
  • Sphinn
  • del.icio.us
  • Facebook
  • Google
Filed under: code, jquery, videotutorial, , ,