Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1052427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:05:31+00:00 2026-05-16T17:05:31+00:00

I created login from that when clicking submit button sends variables to login_success.php page.but

  • 0

I created login from that when clicking submit button sends variables to login_success.php page.but I want to make that when I click submit button login form will be close. I can close form using Jquery

<script type="text/javascript">
$(document).ready(function(){
 $("button").click(function(){
   $(".loginform").hide();
 });
});
</script>

But this time form does not sends request to .php file. I made it like addin script to .php file and then redirected to index.html site.It also good but I can see reflection.How can I combine them?

this is my form

<div class="loginform">
  <form action="php/login.php" method="post" id="login">

        <fieldset class="loginfield">
                    <div>
            <label for="username">User Name</label> <input type="text" id="username" name="username">
        </div>
        <div>
            <label for="password">Password</label> <input type="password" id="password" name="password">
        </div>
    </fieldset>
      <button type="submit" id="submit-go" ></button>
    </form>
</div>

Edit
I used function as NAVEED sad .I installed FireBug in firefox and I can see that my form validation works normal.It sends and request to login.php But I cant make any change on my form.It does not close or $arr values not shown on div tags.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T17:05:32+00:00Added an answer on May 16, 2026 at 5:05 pm

    You should use JSON/AJAX combination:

    Downlod jQuery

    If your form look like this:

    <script type="text/javascript" src="jquery-1.4.2.js"></script>
    <script type="text/javascript" src="ajax.js"></script>
    
    <div id='errors'></div>
    <div class='loginform' id='loginform'>
      <form action="php/login.php" method="post" id="login">
         Username:<input type="text" id="username" name="username">
         Password:<input type="password" id="password" name="password">
         <button type="submit" id="submit-go" value='Login'></button>
      </form>
    </div>
    

    Your jQuery Code in ajax.js file to submit the form and then get data from ‘php/login.php‘ in JSON and fill the required DIVs. If login is id of the form.

    jQuery('#login').live('submit',function(event) {
        $.ajax({
            url: 'php/login.php',
            type: 'POST',
            dataType: 'json',
            data: $('#login').serialize(),
            success: function( data ) {
                for(var id in data) {
                    jQuery('#' + id).html(data[id]);
                }
            }
        });
        return false;
    });
    

    your login.php file as described in form action attribute:

    $username = $_POST['username'];
    $password = $_POST['password'];
    
    if( $username and $password found in database ) {
    
      // It will replace only id='loginform' DIV content 
      // and login form will disappear
      $arr = array ( "loginform" => "you are logged in" ); 
    
    } else {
    
      // It will replace only id='errors' DIV content
      $arr = array ( "errors" => "You are not authenticated. Please try again" );
    
    }
    echo json_encode( $arr );
    

    More Detail:

    • How to submit a form in ajax/json:
    • General jquery function for all forms
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help. I had created login page from that page user with
I've created a login page and registration page and now I want to use
I created a simple login screen that stacks a login button, the username and
I have created a login page using a nice guide that I found about
I want facebook login in my website For that I followed these steps: 1)Created
I have created login page forced login in several pages. Now i need to
I created Aspx login page and ext js login form in it ExtJs code
I created a login page using spring_security_check. Here: <form name='f' action=/sec_test/j_spring_security_check method='POST'> <table> <tr>
i have created one login and register view in that view after login user
I've created a login page and in the db table i have a field

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.