html - Can you tell me what's wrong with this PHP form? -
i'm trying make simple website in ask user name , dob in order output "hello (name) (age) years old , graduate in (graduation date). feel code right when submit form leads me blank page.
my code: html
<body> <center> <form action="aform.php" method="post"> name:<input type="text" name="name" /> <br /> date of birth: <input type="text" size="4" placeholder="mm" name="month" /> <input type="text" size="4" placeholder="dd" name="day" /> <input type="text" size="6" placeholder="yyyy" name="year" /> <input type="submit" name="submit" value="submit" /> <br /> </form> </center> </body>
php:
<?php if($_post["submit"]){ $name = $_post["name"]; $day = $_post["day"]; $month = $_post["month"]; $year = $_post["year"]; $datedisplay = date("yyyy"); $birth = array($day,$month,$year); if($name = $year = $month = $day = ""){ echo "you must fill out everything!"; } else if($year = $month = $day > 0) { $yourage = 2014 - $year; $gradyear = $year + 22; $graddate = "6/tba/$gradyear"; echo "hello" . $name . ", are" . $yourage . "years old , graduate college in" . $graddate ; } } ?>
sorry if presented wrong i'm new website.
your tests wrong. here corrected code:
<?php if($_post["submit"]) { $name = $_post["name"]; $day = $_post["day"]; $month = $_post["month"]; $year = $_post["year"]; $datedisplay = date("yyyy"); $birth = array($day,$month,$year); if(empty($name) || empty($year) || empty($month) || empty($day)) { echo "you must fill out everything!"; } else if($year > 0 && $month > 0 && $day > 0) { $yourage = 2014 - $year; $gradyear = $year + 22; $graddate = "6/tba/$gradyear"; echo "hello" . $name . ", are" . $yourage . "years old , graduate college in" . $graddate ; } } ?>
Comments
Post a Comment