如果他/她不满年龄或以上的陈述

时间:2017-10-23 09:48:57

标签: php forms

问题是我想当有人把他们的年龄放入输入字段时,if语句显示如果他/她未成年人打印为小孩,并且如果他/她比指定年龄大,则打印大家伙。

<form action="preformR6.php" method="POST">
  <input type='hidden' name='id' value='<?php print (int)$_POST['id']; ?>' />
  FirstName: <input type="text" name="firstname" value='<?php print $name; ?>' ><br>
  LastName:<input type="text" name="lastname"  value='<?php print $lastname; ?>' ><br/>
  Psn ID: <input type="text" name="psn"   value='<?php print $psn; ?>'> <br/>
  Age: <input type="text" name="age" value='<?php print $age;?>'> <br/>
  <input type="submit">    
</form>

<?php
   if( $_POST["firstname"] || $_POST["lastname"] || $_POST["psn"] || $_POST["age"]) {
      echo "Your Firstname Is :". $_POST['firstname']. "<br /><br/>";
      echo "Your Lastname Is :". $_POST['lastname']."". "<br/><br/>";
      echo "Your Psn ID Is :". $_POST["psn"]. "<br/><br/>";
      echo "Your Age Is :".$_POST["age"]. "<br/><br/>";
      exit();
   }
   if($_POST["age"] < 18){    
        echo 'kido';     
   } else{
        echo 'big guy';     
   }
 ?> 

0 个答案:

没有答案