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

  • SEARCH
  • Home
  • 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 7708505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:37:44+00:00 2026-06-01T00:37:44+00:00

I have two forms on my website, and I use jQuery to submit them,

  • 0

I have two forms on my website, and I use jQuery to submit them, to my PHP script.

These are the forms:

<form method="post" class="settings-form" id="passwordSettings">
  <label id="npasswordbox" class="infoLabel">New Password: </label>
  <input type="password" name="npassword" size="50"  value="" >

  <div class="move"></div> 

  <label id="cnpasswordbox" class="infoLabel">Confirm: </label>
  <input type="password"  name="cnpassword" size="50" value="" >

  <button class="btn" name="passwordSetings" style="margin-left:185px" type="submit">Save </button> 

</form><!-- end form -->

And the next:

<form method="post" class="settings-form" id="normalSettings">
  <label id="npasswordbox" class="infoLabel">New Username: </label>
  <input type="text" name="username" size="50"  value="" >

  <div class="move"></div> 

  <button class="btn" name="normalSettings" style="margin-left:185px" type="submit">Save </button> 

</form><!-- end form -->

Here is the jQuery I have written for these two forms:

$(function() {
    $('form#passwordSettings').submit(function(){
        $('#status').hide();
        $.post(
            'index.php?i=a&p=s', 
            $('form#passwordSettings').serialize(),
            function (data) {
                proccessPWData(data);
            }
        );
        return false;    
    });
});

function proccessPWData (data) {
    $('#status').hide().html('');
    if(data=='success'){
        $('form#normalSettings').fadeOut();
        $('html, body').animate({scrollTop:0});
        $("#status").removeClass();             
        $('#status').addClass('alert alert-success').html('You have successfully changed your personal settings.<br />').slideDown().delay(5000);
        redirect("/account");
    }
    else {
        $('html, body').animate({scrollTop:0});     
        $('#status').removeClass().addClass('alert alert-error').html(data).fadeIn();
        setTimeout(function(){
            $('#status').slideUp("slow");
        },7000);
    }
}

$(function() {
    $('form#normalSettings').submit(function(){
        $('#status').hide();
        $.post(
            'index.php?i=a&p=s', 
            $('form#normalSettings').serialize(),
            function (data) {
                proccessData(data);
            }
        );
        return false;    
    });
});

function proccessData (data) {
    $('#status').hide().html('');
    if(data=='success'){
        $('form#normalSettings').fadeOut();
        $('html, body').animate({scrollTop:0});
        $("#status").removeClass();             
        $('#status').addClass('alert alert-success').html('You have successfully changed your personal settings.<br />').slideDown().delay(5000);
        redirect("/account");
    }
    else {
        $('html, body').animate({scrollTop:0});     
        $('#status').removeClass().addClass('alert alert-error').html(data).fadeIn();
        setTimeout(function(){
            $('#status').slideUp("slow");
        },7000);
    }
}

And then the PHP code:

if(isset($_POST['normalSettings']))
{
    $username = inputFilter($_POST['username']);
    if(!$username){
        $error ="no username";
    }
    if(!$error){
        echo "success!";
    }
} 

if(isset($_POST['passwordSettings']))
{
    $password = inputFilter($_POST['npassword']);
    if(!$username){
        $error ="no pw";
    }
    if(!$error){
        echo "success!";
    }
} 

My problem is, that whenever I submit one of these forms, I see the form with my $error in the #status div.

How can I have multiply forms on one page, but submit the correct ones?

  • 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-06-01T00:37:46+00:00Added an answer on June 1, 2026 at 12:37 am
    $(function() {
        $('form#passwordSettings').submit(function(e){
            e.preventDefault(); // prevents the default action (in this case, submitting the form)
            $('#status').hide();
            $.post(
                'index.php?i=a&p=s', 
                $('form#passwordSettings').serialize(),
                function (data) {
                    proccessPWData(data);
                }
            );
            return false;    
        });
    });
    

    or you could just give an hidden input-field with it

    <input type="hidden" name="_normalSettings">
    

    and check in your PHP

    if (isset($_POST['_normalSettings']) // ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two forms, form A and form B. These forms must differ in
I have a login form for my website. This login form have two text
I have a form where depending on the website's brand one of two input
I have two forms. The first form is the mainForm, this never goes anywhere.
I have two forms on a page (one is being grabbed by AJAX). I
I have two forms in my rails app. They both exist in separate tabs
I have two forms, one with a radio button that users must select to
I have two forms on one page and want to have the input boxes
I (currently) have two forms, one that needs to call the other. In other
How can two forms share the same inputs? I have two forms, one for

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.