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

The Archive Base Latest Questions

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

I have problem with forms on one file. The problem is that when I

  • 0

I have problem with forms on one file.
The problem is that when I click submit … it submits the first form data instead of the form that the person filled even though as you can see from the code below that I specified a certain id for each form.

I am using a php file to submit the data to mysql

here is my code:

case 'upd_chpt':
if($_POST['does'] == 'upd_chpt')
{
    $chId = $_POST['chId'];
    $name = $_POST['name'];
    $nums = $_POST['nums'];
    $mngs = $_POST['mang'];
    $ch_trans = $_POST['ch_trans'];
    $ch_down = $_POST['ch_down'];
    $ch_translate = $_POST['ch_translate'];
    $ch_clean = $_POST['ch_clean'];
    $ch_editor = $_POST['ch_editor'];
    if(!empty($chId) && !empty($name) && !empty($nums) && !empty($mngs) && !empty($ch_trans))
    {
        $mnG = explode(',' , $mngs);
        $qup = $db->query("UPDATE chapter SET ch_name = '".$name."', chapter_num = '".$nums."', manga_id = '".$mnG[0]."', manga_title = '".$mnG[1]."', manga_name = '".$mnG[2]."', ch_down = '".$ch_down."', ch_translate = '".$ch_translate."', ch_clean = '".$ch_clean."', ch_editor = '".$ch_editor."', ch_trans = '".$ch_trans."' WHERE ch_Id = '".$chId."' ");
        if($qup)
        {
            echo "updated successfully";
        }
        else
        {
            echo "erorr ";
        }
    }
    else
    {
        echo "please fill all the fields !";
    }
}
break;

html code :

<form id="edit_{$ch[ch].ch_Id}">
    <input type="hidden" name="chid" value="{$mn[mn].ch_Id}" />
    <label>chapter number</label>
    <input type="text" id="chaptr" name="chaptr" value="{$ch[ch].chapter_num}" class="short" />
    <label>chapter title </label>
    <input type="text" id="name" name="name" value="{$ch[ch].ch_name}" class="short" />
    <label>manga related to chapter</label>
    <select id="mansga" name="manga">
        {section name='mn' loop=$mng}
            <option value='{$mng[mn].mn_Id},{$mng[mn].mn_title},{$mng[mn].mn_name}' {if $mng[mn].mn_Id==$ch[ch].manga_id}selected="true" {/if}>
                {$mng[mn].mn_name}
            </option>
        {/section}
    </select>
    <label>chapter link</label>
    <input type="text" id="ch_down" name="ch_down" value="{$ch[ch].ch_down}" class="short" />
    <label>all credit goes to</label>
    <input type="text" id="ch_trans" name="ch_trans" value="{$ch[ch].ch_trans}" class="short" />
    <label>translated by</label>
    <input type="text" id="ch_translate" name="ch_translate" value="{$ch[ch].ch_translate}" class="short" />
    <label>cleaned by</label>
    <input type="text" id="ch_clean" name="ch_clean" value="{$ch[ch].ch_clean}" class="short" />
    <label>edited by</label>
    <input type="text" id="ch_editor" name="ch_editor" value="{$ch[ch].ch_editor}" class="short" />
    <label><input type="submit" class="submit" value="تعديل" /></label>
</form>

javascript :

$('[id^=edit_]').submit(function(){
    var id = $(this).attr('id').split('_')[1];
    var name = $('#name').val();
    var nums = $('#chaptr').val();
    var mang = $('#mansga').val();
    var ch_trans = $('#ch_trans').val();
    var ch_down = $('#ch_down').val();
    var ch_translate = $('#ch_translate').val();
    var ch_clean = $('#ch_clean').val();
    var ch_editor = $('#ch_editor').val();
    $.post("action.php", {does: 'upd_chpt' ,ch_trans:ch_trans, ch_down:ch_down, ch_translate:ch_translate , ch_clean:ch_clean , ch_editor:ch_editor , chId:id , name: name, nums: nums, mang:mang},function(m){
        alert(m);
    });
    return false
});

can this code be changed ? and be only php + html without javascript ! … because I think that id=”” is the problem

  • 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-31T10:00:17+00:00Added an answer on May 31, 2026 at 10:00 am

    the mistake was on the second line
    {$mn[mn].ch_Id} should be {$ch[ch].ch_Id}

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have encountered a problem in my application. I have two forms, one that
so here's the problem I have one form, it outputs search results after submit,
I have an InfoPath form with several fields on, the problem is that one
My problem is this one, I am using Sharepoint 2010, I have a form
I am facing a problem to submit two forms with one JavaScript function. In
I have 3 elements and one form with a button: <input type=submit value=Follow All
In my application I have a Form that for one of the top level
I have a problem in a Windows Forms application with Bitmap.Save failing when I
I have a problem with opening CF.NET forms using VSTS 2008. It uses the
I have a problem with a ClickOnce deployment of a Windows Forms application. When

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.