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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:14:14+00:00 2026-06-03T05:14:14+00:00

I have a form that i want to submit comments to a database containing

  • 0

I have a form that i want to submit comments to a database containing film information. In the same div tag as the form as i have a php script that loads the comments from the database relating to the film_id people are commenting on.

The form code is this

<p>Add a Comment</p>
<form id="addCommentForm" method="post">
<div>
<input type="hidden" name="hidden" id="hidden" value="54">
<label for="name">Your Name</label>
<input type="text" name="name" id="name" />

<label for="body">Comment Body</label>
<textarea name="comment" id="comment" cols="20" rows="5"></textarea>

<input type="submit" id="comment" class="button" value="Submit" />
</div>
</form>

The hidden value contains an id number for the film the people are commenting on. I have this javascript –

<script type="text/javascript">
                                    $(".button").click(function() {

        var name = $("input#name").val();
        var comment = $("input#comment").val();
        var filmnumber = $("input#hidden").val();

        var dataString = 'name='+ name + '&comment=' + comment + '&filmnumber=' + filmnumber;

    $.ajax({
      type: "POST",
      url: "comment.php",
      data: dataString,
      success: function() {

        $('#<?php echo $row['Films_ID'] ?>').fadeOut('slow');
    document.getElementById(<?php echo $row['Films_ID'] ?>).innerHTML=xmlhttp.responseText;
    $('#<?php echo $row['Films_ID'] ?>').fadeIn('slow');
      }
     });

I want it to send the data to my php page called comment and then refresh the div (the div number is the film_id relating to the comment).

My php page that i want it to send to is this –

<?php

    $comment_name =  $_POST["name"];
    $comment_body =  $s_POST["comment"];
    $film_no =  $s_POST["filmnumber"];

    // Connects to your Database 
     mysql_connect("localhost", "****", "****") or die(mysql_error()); 
     mysql_select_db("ignitet1_CheckFilm") or die(mysql_error()); 

    $query1 = "INSERT INTO film_comments (comment_id,Films_ID,name,comment) 
    VALUES ('','$film_no', '$comment_name','$comment_body')";
    $runquery1 = mysql_query($query1)or die(mysql_error()); 

?>

Thanks for your help guys!

  • 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-03T05:14:15+00:00Added an answer on June 3, 2026 at 5:14 am

    Use AJAX like you are doing to add entries, either get the updated list in the same call that adds the new entry or make a second call afterwards and use the results of this to populate the comments on the page.

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

Sidebar

Related Questions

I want to submit a form that have many checkboxes with different values, using
i have a form (made through codeigniter) that i want to submit with ajax
I have a form on a non-SSL page that I want to submit as
I have a form that when my users click submit, I first want to
I have a html form with no submit button. I want to submit that
I have a <div id=comment_posting_holder> tag that holds a form with two elements: a
I have a form that is submitting comments. I want 'forward_to' to move to
Okay all, I have a form that I want users to fill out. When
I have a form element that I want to address via javascript, but it
I want to have a Form that can Add or Delete TextFields. I was

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.