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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:27:18+00:00 2026-06-02T18:27:18+00:00

I have a table disease , which has the columns diid , diseasename and

  • 0

I have a table disease, which has the columns diid, diseasename and descrption, in a database called hcp.

I want to simply input from a HTML form; here is my code so far.

<html><head><title>Disease Inssert</title></head>
<body>
<form action="diseaselist.php" method="post">
Disease Name : <input type="text" name="txtDiseaseName" id="textbox" /><br />
Description : <input type="text" name="txtDiseaseDescription" id="textbox" /><br />
<input type="submit" name="btnDiseaseSubmit" id="button"/>

</form>
</body>
</html>

<?php
mysql_connect("localhost","root","");
mysql_select_db("hcp");

if($_REQUEST['btnDiseaseSubmit'])
{
$queryDiseaseInsert="INSERT INTO  disease (`diseasename` ,`description`) VALUES ('".$_REQUEST['txtDiseaseName']."', '".$_REQUEST['txtDiseaseDescription']."');";

$resultDI=mysql_query($queryDiseaseInsert) or die(mysql_error());
}
?>

After submitting, page is redirecting to the diseaselist.php, but the data is not saving in the database.

Can anyone see anything wrong with my query?

  • 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-02T18:27:19+00:00Added an answer on June 2, 2026 at 6:27 pm

    The form is submitting directly to the list <form action="diseaselist.php" method="post">
    .
    The code saving to the database is never executed.

    You could create an intermediate page, let’s say process.php containing the code for adding to the database:

    <?php
    mysql_connect("localhost","root","");
    mysql_select_db("hcp");
    
    if($_REQUEST['btnDiseaseSubmit'])
    {
        $queryDiseaseInsert="INSERT INTO  disease (`diseasename` ,`description`) VALUES ('". mysql_real_escape_string($_REQUEST['txtDiseaseName'])."', '".mysql_real_escape_string($_REQUEST['txtDiseaseDescription'])."');";
    
       $resultDI=mysql_query($queryDiseaseInsert) or die(mysql_error());
       // insert is complete, redirect to list
       header("location: diseaselist.php");
    } else {
       // the form was not submitted
       // redirect back to the form or show error message
    }
    
    ?>
    

    Changes:

    • added mysql_real_escape_string
    • after insert, send the header instruction to redirect the browser to the list

    Now, in your current file, leave only the html code and update the action attribute to submit the form to the process.php script:

    <html><head><title>Disease Inssert</title></head>
    <body>
    <form action="process.php" method="post">
    Disease Name : <input type="text" name="txtDiseaseName" id="textbox" /><br />
    Description : <input type="text" name="txtDiseaseDescription" id="textbox" /><br />
    <input type="submit" name="btnDiseaseSubmit" id="button"/>
    
    </form>
    </body>
    </html>
    

    Changes:

    • updated the form action attribute to process.php
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have table in my database which has fields of ID,NAME,CONTEXT. I am showing
I have table with 3 columns A B C. I want to select *
I have table with 3 columns: id (of person), city (which person visited) and
I have table called product review with columns productreviewid , productid , shopperid ,
I have table named as contacts which has nearly 1.2 million records we use
I have table inside a div tab. The table has 40 rows in it
i have table structure with 3 colums (column1, column2, column3) and i want to
I have table in data base name train delay, with columns train number(int), DelayTime(int),
I have table A in Oracle that has a primary key (id). I need
I have the following database table with information about people, diseases, and drugs: PERSON_T

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.