html - Php echo not working on empty form field test -
i'm finding echo isn't working in scripts. stripped down script below i've been using debug this, result has been same.
perhaps can see simple i've overlooked. appreciated.
additional details:
- location: http://www.example.com/include/sandbox.php
- the web-server can execute php-scripts:
phpinfo();
presents php version 5.3.24. - no header lines worry about.
(i'm wanting check field not empty before submitting database, , provide prompts or echo on submit.)
<?php if($_server['request_method'] == 'post'){ if(!isset($fielda)){ echo "error: submission field empty."; } else{ echo "success! submitted field wasn't empty."; } } ?> <h1> example title </h1> <form method="post" action="sandbox.php" > <input type="text" name="fielda" value="" /> <br /> <input type="submit" name="submit" /> </form>
if($_server['request_method'] == 'post'){ .......... }
try one. or change if condition like,
if(!isset($_post['fielda'])){ if(empty($_post['fielda'])) { echo "error: submission field empty."; } } else{ echo "success! submitted field wasn't empty."; }
Comments
Post a Comment