dataValid.php - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of dataValid.php.php
- <?php
- $valid=true;
- if (empty($_POST["nickname"])){
- $valid=false;
- }
- if (empty($_POST["height"])){
- $valid=false;
- }
- elseif ($_POST["height"]<0 || $_POST["height"]>250){
- $valid=false;
- }
- if (empty($_POST["weight"])){
- $valid=false;
- }
- elseif ($_POST["weight"]<0 || $_POST["weight"]>250){
- $valid=false;
- }
- if ($valid){
- $bmi=$_POST["weight"]/(($_POST["height"]/100)**2);
- echo "{$_POST["nickname"]}, your BMI is {$bmi}";
- }
- else{
- echo "Invalid";
- }
- if (count($_POST["teacher"])==0){
- echo "怎會咁多老師都沒有一個是你欣賞的!";
- }
- else {
- foreach ($i as $_POST["teacher"]){
- echo "I like {$i} <br>";
- }
- }
- ?>