MUST be a number, you entered: " . $num; //empty out the invalid data $num = ""; } if($error == ""){ //if error is an empty string //no errors, do the math $result = $num . " squared is " . ($num * $num); }else{ //there were problems, concatentate the TRY AGAIN message $error .= "
Please Try Again"; } } //NOTE: //the first two echos below show the errors or the result (these are empty the first time the page loads) //the third of the following echo'es makes this page self-referring //the name of the current file is outputted placed in the action of the form //and the fourth of the following echo'es is what makes the form sticky, the //number previously entered on the form, is automatically displayed in the value of the text input box ?>

Enter a number: