Validate alphanumeric characters use PHP
HTML Code:
Copy this code and save as form.php
<form action="validate.php" method="post">
<input name="name" id="name" type="text"/>
<input name="submit" type="submit" value="Validate">
</form>
PHP Code:
Copy this code and save as validate.php
<form action="validate.php" method="post">
<input name="name" id="name" type="text"/>
<input name="submit" type="submit" value="Validate">
</form>
PHP Code:
Copy this code and save as validate.php
<?
$name = $_REQUEST['name'];
if(!ereg('^[[:alnum:]]+$',$name)){
$name = $_REQUEST['name'];
if(!ereg('^[[:alnum:]]+$',$name)){
echo "Not a alphanumeric characters";
} else {
echo "Valid alphanumeric characters";
}
?>
} else {
echo "Valid alphanumeric characters";
}
?>
No comments:
Post a Comment