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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:10:50+00:00 2026-06-06T02:10:50+00:00

I have created a form that contains fields used to accept a floating value

  • 0

I have created a form that contains fields used to accept a floating value as input. My goal is to be able to store these values in a DB and use them later on. Everything I’ve tried so far has resulted in failure.

I have tried changing the input field type from text to number, float, and even number with a small step size. It seems that when I request the value of the field with php and then send it to my DB, something goes wrong and stores only the nearest whole number. Ideas?

My form code is:

<form name ="chemAdd"  action="submitChemData.php" method="POST" id="chemData">

                <fieldset>
                <legend>Chemical Information</legend>
                <label for="chemName">Chemical Name:</label>
                <input type="text" name="chemName" />

                <label for="chemFormula">Molecular Formula:</label>
                <input type="text" name="chemFormula" />
                </fieldset>
                <br />

                <fieldset>
                <legend>Antoine Constants</legend>
                <label for="A">A:</label>
                <input type="number" name="A" size="10" min="0" max="9999" step="0.00000001" />

                <label for="B">B:</label>
                <input type="float" name="B" size="10"/>

                <label for="C">C:</label>
                <input type="text" name="C" size="10"/>

                <br /><br />

                <label for="unitT">Unit (Temperature):</label>
                    <select name="unitT" >
                        <option value="K">Kelvin</option>
                        <option value="C">Celcius</option>
                        <option value="F">Fahrenheit</option>
                    </select>

                <label for="unitP">Unit (Pressure):</label>
                    <select name="unitP" >
                        <option value="P">Pascal</option>
                        <option value="Hg">mm Hg</option>
                        <option value="bar">bar</option>
                    </select>

                </fieldset>
                <br />
                <fieldset>
                <legend>Reference Information</legend>
                <label for="Tmin">Temp. Minimum:</label>
                <input type="float" name="Tmin" size="10"/>

                <label for="Tmax">Temp. Maximum:</label>
                <input type="float" name="Tmax" size="10"/>
                <br /><br />
                <label for="Reference">Reference:</label>
                <input type="text" name="Reference" size="60"/>

                </fieldset>
                <br />
                <input type="submit"  value="Add to Database" id="submit" />    

                </form>
            </form>

My PHP code is:

  require_once 'dbConnectChem.php';


$name = trim(strtoupper($_REQUEST['chemName']));  
$formula= trim(strtoupper($_REQUEST['chemFormula']));  
$A =  $_REQUEST['A']; 
$B = $_REQUEST['B']; 
$C = $_REQUEST['C']; 
$unitT = $_REQUEST['unitT']; 
$unitP = $_REQUEST['unitP']; 
$Tmin = $_REQUEST['Tmin']; 
$Tmax = $_REQUEST['Tmax']; 
$Reference = $_REQUEST['Reference']; 


//INSERT Query
mysql_query("INSERT INTO Antoine (Name,Formula,A,B,C,unit_T,unit_P,Tmin,Tmax,Reference) VALUES ('{$name}','{$formula}','{$A}','{$B}','{$C}','{$unitT}','{$unitP}','{$Tmin}','{$Tmax}','{$Reference}') ")
    or die(mysql_error());
  • 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-06T02:10:52+00:00Added an answer on June 6, 2026 at 2:10 am

    Use DECIMAL data type instead of Float. AS described in this link, sometimes floating point values leads to issues, while Decimal works fine.

    Use it like this way :

    CREATE TABLE t1 (i INT, d1 DECIMAL(9,2), d2 DECIMAL(9,2));
    

    Here 9 is the precision and 2 is the scale.Change it accordingly

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

Sidebar

Related Questions

I have created a macro for excel which will pop up form that contains
I've created an app which contains form and that have to filled up in
I have created a form that is used for both adding and editing a
I have an asp.net text form that contains numerous decimal fields that are optional.
I have a form which contains a whole heap of data entry fields that
I have an HTML Form that contains 20 sets of fields. Here are 2
I have created a list form that gets attached to a main form in
I have created a form with knockout that will allow the ability to give
if i have created a view model and have a partial form that is
I have created a non-form c# program that uses the NotifyIcon class. The text

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.