By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,747 Members | 2,011 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,747 IT Pros & Developers. It's quick & easy.

Newbie. Just starting PHP. . . need help

pr00xysp00f3r
P: 2
I am just starting to learn PHP and as I read through my textbook, I am uploading the code examples, to try them out and get hands-on experience and all have worked up until this point. I am just curious as to what I have done wrong with this code.

<html>
<head>
<title>HelloForum.php</title>
</head>
<body>

<?
//Print a greeting if the form was submitted
if ($_POST['user'])
{
print "Hello, ";
// Print what the user submitted in the forum
print $_POST['user'];
print "!";
}
else
{
// otherwise display the forum!
print <<<_HTML_
<form method="POST" action="$_SERVER[PHP_SELF]">
Your Name: <input type="text" name="user">
<br/>
<input type="submit" value="Say Hello">
</form>
_HTML_;
}
?>

</body>
</html>
May 1 '07 #1
Share this Question
Share on Google+
2 Replies


100+
P: 136
Hi,

u should write

[PHP]if (isset($_POST['user']))[/PHP]

I am just starting to learn PHP and as I read through my textbook, I am uploading the code examples, to try them out and get hands-on experience and all have worked up until this point. I am just curious as to what I have done wrong with this code.

<html>
<head>
<title>HelloForum.php</title>
</head>
<body>

<?
//Print a greeting if the form was submitted
if ($_POST['user'])
{
print "Hello, ";
// Print what the user submitted in the forum
print $_POST['user'];
print "!";
}
else
{
// otherwise display the forum!
print <<<_HTML_
<form method="POST" action="$_SERVER[PHP_SELF]">
Your Name: <input type="text" name="user">
<br/>
<input type="submit" value="Say Hello">
</form>
_HTML_;
}
?>

</body>
</html>
susen
May 2 '07 #2

pr00xysp00f3r
P: 2
THANK YOU :)

Hi,

u should write

[PHP]if (isset($_POST['user']))[/PHP]



susen
May 2 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.