Jump to content

Recommended Posts

I want to see if a user's input is numeric.

 

<form action='<?php $_SERVER['PHP_SELF'] ?>' method='post'>
  <input type='text' name='id' size='10' />
</form>

<?php

$id = $_POST['id'];

/* checks if $id is numeric */

?>

 

I tried using is_numeric but that gave me an error. Any help will be appreciated. Thanks.

Link to comment
https://forums.phpfreaks.com/topic/67202-_post-numeric/
Share on other sites

Hi,

 

Check this code...

 

<form action='<?php $_SERVER['PHP_SELF'] ?>' method='post'>
  <input type='text' name='id' size='10' />
  <input type='submit' name='btnClick' value='Click Me' />
</form>
<?php
/* checks if $id is numeric */
if(isset($_POST['btnClick']))
{
if(is_numeric($_POST['id']))
{
	echo "The Entered Value is Numeric";
}
else
{
	echo "The Entered Value is not Numeric";
}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/67202-_post-numeric/#findComment-337109
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.