PHP form field not displayed [was: Newbie problem.]
Hello good people.
I have a very basic question to ask. ![]()
Here is my index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>PHP Test</title>
<style>
body {
margin:50px;background-color:#232323; font-family:sans-serif; color:#B7B7B7; font-size:13px;
}
input, textarea {
border: #464646 solid 1px; background-color:#1C1C1C; font-family:sans-serif; color:#CECECE; font-size:10px; margin-top:15px; margin-bottom:15px;
}
#submit {
font-size:13px;
}
</style>
</head>
<body>
<form action="index.php" method="post">
What is your name?<br />
<input type="text" name="name" /><br />
What is your age?<br />
<input type="text" name="age" /><br />
<textarea type="text" name="tekstas" rows="5" cols="40">Your message.</textarea><br /><br />
<input type="submit" value="Go!" id="submit"/>
</form>
</body>
</html>
And index.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style>
body {
margin:50px;background-color:#232323; font-family:sans-serif; color:#B7B7B7; font-size:13px;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>PHP Result</title>
</head>
<body>
<?php
settype($_POST["age"], "integer");
echo "Your name is ".$_POST["name"]."<br />";
if ($_POST["age"]!=0) echo "Your age is ".$_POST["age"]."<br /><br />";
if ($_POST["age"]=0 ) echo "Please specify your age."."<br /><br />";
echo "<b>Message:</b><br />".$_POST["tekstas"];
?>
</body>
</html>
The question is:
Why the Age part of php is not working properly? If I leave it black or type zero in the Age <input>, PHP just ignores the "Please specify your age" part of code.