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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:01:07+00:00 2026-06-02T03:01:07+00:00

I have a php form that is adding information to my sql database, i

  • 0

I have a php form that is adding information to my sql database, i need it to only accept numbers in the text box.

This is my php form

<form id="MakeBid" action="MakeBid.php" method="POST">
    <input type="hidden" name="propertyID" value="1" />
    <div>Bid Now
        <input type="text" name="pricesoldfor" />
    </div>
    <input id="submit" input type="submit" value="Submit" />
</form>
  • 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-02T03:01:10+00:00Added an answer on June 2, 2026 at 3:01 am

    Client-side for feedback without loading, you can do something like

    <form [...] onsubmit="if( !this.pricesoldfor.match(/\d+/) ) { 
         alert('Please enter only numbers for the price!'); return false; 
    }">
    

    (I’ve written this example inline – as your form will probably be larger, I would advise you not to use the attribute onsubmit and instead attach a proper event handler. Have a look at preventDefault() as well as this is usually a better alternative to return false.)

    What you will really need to do is validate in your PHP (server-side) that it is only numbers before you save it to the database. For example like this:

    if((string)(int)$input === $input) { /*was a number*/ } else { /*was not a number*/ }
    

    Bear in mind both of these will only allow full numbers (integers), so no “35.43” or similar. Have a look at is_numeric()

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

Sidebar

Related Questions

I have an html/php form that updates entries on the database server. I need
I have a form that looks like this. <form action=index.php method=post> <select name=dropdownOption> <option
I have a page like this: <form class=ajax method=post action=add_item.php> [text input] [submit button]
I have a php form that has a known number of columns (ex. top
I currently have a PHP form that uses AJAX to connect to MySQL and
i have a PHP contact form that submits data, and an email...: <?php $dbh=mysql_connect
(Using MySQL and PHP) I have a search form that will allow my users
I have made a form that accepts query and executes it through php. I
I have a js and html form that submits through php. Once submitted, the
I have a form (signup.php) that pops up in a nyroModal window when I

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.