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 9251259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:39:05+00:00 2026-06-18T10:39:05+00:00

I am currently learning forms and Ajax posting without a page refresh. I have

  • 0

I am currently learning forms and Ajax posting without a page refresh. I have tree forms and one submit button. I have assigned php variables to each input field that will take the value of what’s typed in. The value is echoed for each input box. Is it possible to submit all three forms at the same time? And if yes, how would I submit these values to a MySQL database after the button click?

Ajax:

function() {
    $.ajax({
        type: "POST",
        url: "posting.php",
        data: { 
            "name": $("#name").val(),
            "age": $("#age").val(),
            "phone": $("#phone").val(),
            "email": $("#email").val(),
            "job": $("#job").val(),
            "hobby": $("#hobby").val(),
        },
        success: function(data) {
            $("#inputResult").html(data);
        }
    });
}

PHP

if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
    if (isset($_POST['name'])) {
        $name = $_POST['name'];
        echo '<div id="name_input"><h2 class="lastTab">Name:</h2>' . $name . '</div>';
    }

    if (isset($_POST['age'])) {
        $age = $_POST['age'];
        echo '<div id="age_input"><h2 class="lastTab">Age:</h2>' . $age . '</div>';
    }

    if (isset($_POST['phone'])) {
        $phone = $_POST['phone'];
        echo '<div id="phone_input"><h2 class="lastTab">Phone:</h2>' . $phone . '</div>';
    }

    if (isset($_POST['email'])) {
        $email = $_POST['email'];
        echo '<div id="email_input"><h2 class="lastTab">Email:</h2>' . $email . '</div>';
    }           

    if (isset($_POST['job'])) {
        $job = $_POST['job'];
        echo '<div id="job_input"><h2 class="lastTab">Job:</h2>' . $job . '</div>';
    }       

    if (isset($_POST['hobby'])) {
        $hobby = $_POST['hobby'];
        echo '<div id="hobby_input"><h2 class="lastTab">Hobby:</h2>' . $hobby . '</div>';
    }
}

HTML

<div id="tab-1" class="ui-tabs-panel ui-tabs-hide">
    <form autocomplete="off" method="post" enctype="multipart/form-data" id="postForm1" name="postForm1" class="postForm">
       Name
        <input type="text" id="name" class="detail" name="name" value="" /> 
        Age
        <input type="text" id="age" class="detail" name="age" value="" />   
    </form>         
    </div>.


    <div id="tab-2" class="ui-tabs-panel ui-tabs-hide">
    <form autocomplete="off" method="post" enctype="multipart/form-data" id="postForm2" name="postForm2" class="postForm">
        Phone Number
        <input type="text" id="phone" class="detail" name="phone" value="" />       
        Email
        <input type="text" id="email" class="detail" name="email" value="" /> 
    </form>     
    </div>

    <div id="tab-3" class="ui-tabs-panel ui-tabs-hide">
    <form autocomplete="off" method="post" enctype="multipart/form-data" id="postForm3" name="postForm3" class="postForm">
        Job
        <input type="text" id="job" class="detail" name="job" value="" /> 
        Hobby
        <input type="text" id="hobby" class="detail" name="hobby" value="" />       
    </form>     
    </div>
  • 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-18T10:39:06+00:00Added an answer on June 18, 2026 at 10:39 am

    You can either use javascript to catch the submit of the form or you can trigger a function that you ve created. It doesn t have to be 3 forms or even a form element for the second case to work

    HTML:

    <div id="tab-1" class="ui-tabs-panel ui-tabs-hide">
        <form autocomplete="off" method="post" enctype="multipart/form-data" id="postForm1" name="postForm1" class="postForm">
           Name
            <input type="text" id="name" class="detail" name="name" value="" /> 
            Age
            <input type="text" id="age" class="detail" name="age" value="" />   
        </form>         
        </div>.
    
    
        <div id="tab-2" class="ui-tabs-panel ui-tabs-hide">
        <form autocomplete="off" method="post" enctype="multipart/form-data" id="postForm2" name="postForm2" class="postForm">
            Phone Number
            <input type="text" id="phone" class="detail" name="phone" value="" />       
            Email
            <input type="text" id="email" class="detail" name="email" value="" /> 
        </form>     
        </div>
    
        <div id="tab-3" class="ui-tabs-panel ui-tabs-hide">
        <form autocomplete="off" method="post" enctype="multipart/form-data" id="postForm3" name="postForm3" class="postForm">
            Job
            <input type="text" id="job" class="detail" name="job" value="" /> 
            Hobby
            <input type="text" id="hobby" class="detail" name="hobby" value="" />
            <input type="button" value="SAVE" onclick="saveThem()" />       
        </form>     
        </div>
    

    AJAX:

        function saveThem() {
    
    var name = $.trim($("#name").val());
    var age = $.trim($("#age").val());
    var phone = $.trim($("#phone").val());
    var email = $.trim($("#email").val());
    var job = $.trim($("#job").val());
    var hobby = $.trim($("#hobby").val());
    
    var dataString = 'name='+name+'&age='+age+'&phone='+phone+'&email='+email+'&job='+job+'&hobby='+hobby;
    
          $.ajax({
              type: "POST",
              url: 'http://www.yourdomain.com/something.php',
              data: dataString,
              dataType: "json",
              success: function(data) {
                if(data.response){ alert(data.message); }
                $("#inputResult").html(data);
              }
          });
        }
    

    something.php

    //Get posted variables
    $name = (isset($_POST['name'])) ? strip_tags($_POST['name']) : NULL;
    $age = (isset($_POST['age'])) ? strip_tags($_POST['age']) : NULL;
    $phone = (isset($_POST['phone'])) ? strip_tags($_POST['phone']) : NULL;
    $email = (isset($_POST['email'])) ? strip_tags($_POST['email']) : NULL;
    $job = (isset($_POST['job'])) ? strip_tags($_POST['job']) : NULL;
    $hobby = (isset($_POST['hobby'])) ? strip_tags($_POST['hobby']) : NULL;
    
    //execute your query
    $sql = "INSERT INTO ...";
    
    //Return results back to ajax  
    $result = array(
    'response' => 1,
    'message' => 'We have a success!'
    );
    echo json_encode($result);
    

    So in conclusion is pretty much the same as using php but in the middle there is some javascript.
    Form: create an id for each element that you want to send to your server(php)
    Js: catch values based on element ids and send them to php
    Php: get values, clean them, query or anything else and send results back to js

    EDIT: Using jQuery serialize()

    $('form').submit(function() {
     $dataString = $(this).serialize(); //This will produce the same result, based on input names
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im currently learning python (in the very begining), so I still have some doubts
im currently learning stacks in java and have a quick question. what will the
I have a page using Paypal Payments Standard with buy one now buttons on
I am currently exploring how to write platformindependant software that have forms with inputfieleds
Hi I'm currently learning about the AJAX in jQuery and now I'm trying to
I am in the process of learning Backbone.js. I currently assume that if one
I'm new to C# and have been working on learning database's. Currently I'm trying
I am currently learning PHP, and I'm working on a Registration Form. Somewhere in
I am currently learning how to create classes and using indexers. I have created
I'm currently learning PHP. I've made a simple script @ http://hash.techho.me , only thing

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.