Google Ads

Make Login Form With JQuery v2 PHP Script


Make Login Form With JQuery v2 PHP Script

In this tutorial, we are going to learn How To Make Login Form With JQuery In PHP. This is simple project and it consists username and password.

Username: tutorial
Password: admin
Database Name: login_jquery

You can use it to your Website or System. Download the source code and try it. Enjoy Coding…
Directions:
For JQuery Code

 

Code:
 
  1. <script type="text/javascript">
  2. $(document).ready(function() {
  3. $("#submit").click(function() {
  4. var username = $("#username").val();      
  5.       var password = $("#password").val();
  6.       if(username=='' || password=='' ){
  7.       alert("Please enter the username and password");
  8.       }
  9.       else {            
  10. $.ajax({
  11. type: "POST",
  12. url: "login_function.php",
  13. data: "username="+ username + "&password=" + password ,
  14.       beforeSend: function()
  15.             {
  16.                   $('#display_query').html('Loading....');
  17.             },
  18.             success: function(response)
  19.             {
  20.                   $("#display_query").fadeIn(2000).html(response);
  21.                   document.getElementById('username').value='';
  22.        document.getElementById('password').value='';
  23.             }
  24. });
  25. }            
  26. return false;
  27.       });
  28. });
  29. </script>

 

For PHP Code

Code:
 
  1. <!---
  2. Welcome to the Sourcecodester.com
  3. For more tutorials, kindly visit our website:
  4. https://www.sourcecodester.com/
  5. -->
  6. <?php
  7. $db = mysql_connect('localhost','root','') or die ("Unable to connect to Database Server.");
  8. mysql_select_db ('login_jquery', $db) or die ("Could not select database.");
  9. if(isset($_POST['username']))
  10. {
  11. $username=$_POST['username'];
  12. $password=$_POST['password'];
  13. $query = mysql_query("select * from user where username='$username' and password='$password' ")or die(mysql_error());                  
  14.             $data = mysql_fetch_row($query);
  15.             if($data){      
  16.             echo '<div id="sucess"><img src="image/success.png"></div>';}
  17.             else {
  18.             echo '<div id="error"><img src="image/invalid.png"></div>';}
  19. }?>

 

For CSS Code

Code:
 
  1. <style type="text/css">
  2. #display_query {
  3.       display:none;
  4.       border-radius:3px;
  5.       margin-bottom:4px;
  6. }
  7. table {
  8.       width:300px;
  9.       float:left;
  10. }
  11. label {
  12.       color:blue;
  13.       font-size:20px;
  14.       font-weight:bold;
  15. }
  16. .text_style {
  17.       font-size:18px;
  18.       text-indent:5px;
  19. }
  20. .btn_style {
  21.       font-size:18px;
  22.       border:3px groove #CCC;
  23.       border-radius:7px;
  24.       width:100px;
  25.       font-weight:bold;
  26. }
  27. </style>

 

For HTML Code

Code:
 
  1. <form method="post" name="form" action="">
  2. <table cellspacing="4" cellpadding="4">
  3.       <tr style="background-color:#000000;">
  4.             <td colspan="2" align="center">
  5.                   <h2 style="color:#FFFFFF;">Enter the details below...</h2>
  6.             </td>
  7.       </tr>
  8.       <tr>
  9.             <td>
  10.                   <label>Username</label>
  11.             </td>
  12.             <td>
  13.                   <input name="username" class="text_style" placeholder="Username..." type="text" id="username" />
  14.             </td>
  15.       </tr>
  16.       <tr>
  17.             <td>
  18.                   <label>Password</label>
  19.             </td>
  20.             <td>
  21.                   <input name="password" class="text_style" placeholder="Password..." type="password" id="password" />
  22.             </td>
  23.       </tr>
  24.       <tr>
  25.             <td colspan="2" align="center">
  26.                   <input type="submit" class="btn_style" name="submit" value="Submit" id="submit" />
  27.             </td>
  28.       </tr>
  29.       <tr>
  30.             <td colspan="2">
  31.                   <div align="center" id="display_query"></div>
  32.             </td>
  33.       </tr>
  34. </table>
  35. </form>
  36. <table style="margin-left:100px;">
  37.       <tr>
  38.             <td>
  39.                   <label>Database Name</label>
  40.             </td>
  41.             <td>
  42.                   <span style="color:red;">login_jquery</span>
  43.             </td>
  44.       </tr>
  45.       <tr>
  46.             <td>
  47.                   <label>Username</label>
  48.             </td>
  49.             <td>
  50.                   <span style="color:red;">tutorial</span>
  51.             </td>
  52.       </tr>
  53.       <tr>
  54.             <td>
  55.                   <label>Password</label>
  56.             </td>
  57.             <td>
  58.                   <span style="color:red;">admin</span>
  59.             </td>
  60.       </tr>
  61. </table>
  62. <a href="https://www.sourcecodester.com" style="float:right;">
  63.       <h3>
  64.             Sourcecodester
  65.       </h3>
  66. </a>

 

 

 


Related Post

OKDate v2.1 – Complete Dating Platforms: Web... OKDate v2.1 - Complete Dating Platforms: Website, iOS/Android Apps, BackendOKDate v2.1 - Complete Dating Platforms: Website, iOS/Android Apps, Backend...
EasyAds v1.0.2 – Complex Classified Ads Appl... EasyAds v1.0.2 - Complex Classified Ads ApplicationEasyAds v1.0.2 - Complex Classified Ads ApplicationEasyAds is a Unique Complex Classified Ads Appli...
Ad4earn Adnetwork v1 PHP Script Free Download Ad4earn Adnetwork v1 PHP Script Free Download 1:)upload all files to your server 2:)Chmod logfile.txt to 777 3:)upload .sql file to phpmyadmin 4...
e-Voting System v1 PHP Script e-Voting System v1 PHP Script This Program is created for college election using php...for more info: (email me at [email protected])   ...
Textpattern v4.2.0 Rc 1 Blog PHP Script Download Textpattern v4.2.0 Rc 1 Blog PHP Script Download Create a Beautiful Blog Website using this PHP Script Textpattern is a web application designed...

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *

"