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 I save text inside a textarea so that it can be updated later?

Hello: I receive two error messages when I try to submit a form. The messages are: Warning: mysqli_query() [function.mysqli-query]: Empty query in /home/content/PRIVATE/html/riskyjobs_riskybusiness_Database_TableSetup_riskyjobs_Table_Chapter9_Page5

Can I use a variable from a .php file to give a value to an HTML FormMail form field thus: ? Thank you

What are causes of seeing the actualPHP code in my web browser

How do I know if magic quotes is switched on?



Custom Search