Saturday, 28 September 2013

form variables not passing to php

form variables not passing to php

I'm using php version 5.5.1 and Apache server if this information helps I
have a simple form and I'm trying to pass the form variable to php and
output the value. I am a beginner in php so please excuse me if this is
something obvious, I have tried to solve this myself with the almighty
google but wasn't successful. The html form code is as follows
<html>
<head>
<title>Form</title>
</head>
<body>
<form method="post" action="test1.php">
<input type="text" name="username">
<input type="submit">
</form>
</body>
</html>
Then the php to handle the form is:
<html>
<head>
<title>Form</title>
</head>
<body>
<?php
echo "<h1>Hello " . $_POST["username"] . "</h1>";
?>
</body>
</html>
The output I'm getting no matter what I type into the html form is , Hello
" . $_POST["username"] . ""; ?>
I don't know why it also outputs the ending semi colon and ending php tag
also, maybe this is evidence of what's going wrong here?
Any and all help is appreciated! Thank You.

No comments:

Post a Comment