[Solved]-what's wrong in this Code?
Posted: Thu Jul 21, 2011 8:13 am
Hi all
I'm newbie in php.
Can anyone tell me why this code isn't working? I know i am missing something just cant figure out what. I am trying to test a form that sent a variable through a form to a php scipt like this:
but the php script does not work properly. indeed the first curly braces not work! In other words, when i enter $age = 21 or a number greater 21, the code within FCB (First Curly Braces) is not executed. i see a WhitePage. On the other hand when inter a number less than 21 the seconf Curly Braces work fine and executed. seems the combination operators >= not work fine but i don't know why!!!?
THE PHP SCRIPT:
(It should be noted that, codes are a copy paste from here: Older But Not Wiser and i'm doing this for php-learning ...)
If anyone knows whats wrong could you please explain. thanks
I'm newbie in php.
Can anyone tell me why this code isn't working? I know i am missing something just cant figure out what. I am trying to test a form that sent a variable through a form to a php scipt like this:
Code: Select all
<html>
<head><title>ageist</title></head>
<body>
<form action="ageist.php" method="post">
Enter Your Age: <input name="age" size="2"> <br />
<input type="submit" value="send">
</form>
</body>
</html>THE PHP SCRIPT:
Code: Select all
<html>
<head></head>
<body>
<?php
// retrieve form data
$age = $_POST['age'];
// check entered value and branch
if ($age >= 21) {
echo 'Come on in, we have alcohol and music awaiting you!';
}
if ($age < 21) {
echo "You're too young for this club, come back when you're a little older";
}
?>
</body>
</html> If anyone knows whats wrong could you please explain. thanks