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

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.



Comment on this Question and Answer >>>

ASK A QUESTION

More forms PHP Questions

I am taking over a position from another programmer, and want to change some php code, but part of it has me baffled. The code creates a form and after it is filled, the client wants it to go to a separate thank you page – right now, it re-uses the for

how do i validate the name into form ?

How do I escape data that is going into a database?

How can I access information sent through POST on a form?

how to avoid the refresh or goback to submit the post values in database



Custom Search