<html> <head><title>Button1</title></head>
<body>
<?php
$errors = array () ;
if ( isset ($_REQUEST ["seen_already"]))
{
validate_data ();
if (count($errors)>0 )
{
diplay_errors ();
display_form ();
}
else
{
process_data ();
}
}
else
{
display_form ();
}
function validate_data ()
{
global $errors ;
if (strcmp($_REQUEST ["Number"] , strval (intval($_REQUEST ["Number"]))))
{
$errors [] = "<FONT COLOR='RED'>Sleduet vvesti chislo</FONT>";
}
}
function display_errors ()
{
global $errors ;
foreach ($errors as $err)
{
echo $err , "<BR>" ;
}
}
function process_data ()
{
echo "Celoe chislo ravno".$_REQUEST ["Number"];
}
function display_form ()
{
echo "<FORM METHOD='POST' ACTION='phpinteger.php'>";
echo "Vvedite celoe chislo" ;
echo "<BR>";
echo "<INPUT NAME='Number' TYPE='TEXT' >";
echo "<BR><BR>";
echo "<INPUT TYPE=SUBMIT VALUE='OK' >";
echo "<INPUT TYPE=HIDDEN NAME='seen_already' VALUE='data' >";
echo "</FORM>";
}
?>
</body>
</html>