PHP Questions Home
Categories
Arrays
Files
Forms
Creating PDFs
PHP Errors
Functions
Images
MySQL
Numbers
Others
Strings
Website

PHP Forums
Forums Index
MySQL Forum
PHP Forum
Flash/Actionscript
Javascript
Web design

More PHP
PHP Functions
Top Questions
Ask a Question
PHP Interview Questions
PHP Jobs
Ecommerce
IT Questions
Business Websites

Sponsors

sponsor ad
My Salary
PHP Developer Salary
Advertise Here

How can I check a value entered in a field on my form is a number?


There are several ways that you can check that this is the case. One of the simplest ways is to use a dedicated function, is_numeric - just pass it the value and it'll return true or false depending on whether it is a number or not.

Here's an example:

<?php
$formvalue 
"57a";
if(
is_numeric($formvalue)) { echo "Is a number"; } else { echo "Not a number"; }
?>


This prints 'Not a number' in this instance.



ASK A QUESTION

More forms PHP Questions

How do you check for an empty field in a form?

This may seem simple but I am just starting out. After the action of my submit button on my html page sends the user and the information to my php page how do I get the user back to the page with the form without having to get the user to have to click o

I have a form that I need to do two things: send all the input values to a confirmation/pay page, and send to me via email. Payment is based on what the customer picks (naturally). The way I have it set up is the form action goes to the confirmat

How do I check for an empty field in a form?

How do I check that a valid email address is entered?



Custom Search