Ken2k7 Posted August 29, 2007 Share Posted August 29, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/67202-_post-numeric/ Share on other sites More sharing options...
jagat21 Posted August 29, 2007 Share Posted August 29, 2007 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"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/67202-_post-numeric/#findComment-337109 Share on other sites More sharing options...
Ken2k7 Posted August 29, 2007 Author Share Posted August 29, 2007 Doesn't work. I've tried that. It errored out. Quote Link to comment https://forums.phpfreaks.com/topic/67202-_post-numeric/#findComment-337111 Share on other sites More sharing options...
jagat21 Posted August 29, 2007 Share Posted August 29, 2007 i have tested this code and then posted. Its working fine on my system. Quote Link to comment https://forums.phpfreaks.com/topic/67202-_post-numeric/#findComment-337117 Share on other sites More sharing options...
hostfreak Posted August 29, 2007 Share Posted August 29, 2007 What error do you get? Also there is no need for $_SERVER['PHP_SELF'] as the action url. Anytime your sending data to the current page, you can leave it blank. Quote Link to comment https://forums.phpfreaks.com/topic/67202-_post-numeric/#findComment-337118 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.