Page 1 of 1

Cannot read input from form

Posted: Mon Dec 22, 2008 3:37 pm
by sink
I am just getting started with PHP, so I don't even know where to begin looking.

I am simply trying to read the input from a form, but the variables don't seem to resolve. This is from Meloni's book, PHP, MySQL, and Apache, lesson 11. All the lessons prior to this one worked properly, so I am at a loss to understand why this one doesn't.

My form is defined as:

Code: Select all

<html>
<head>
<title>A simple HTML form</title>
</head>
<body>
<form action="send_simpleform.php" method="POST">
<p><strong>Name:</strong><br/>
<input type="text" name="user"></p>
<p><strong>Message:</strong><br/>
<textarea name="message" rows="5" cols="40"/></textarea></p>
<p><input type="submit" value="send"/></p>
</form>
</body>
</html>
My code is defined as:

Code: Select all

<?php
    echo "<p>Welcome <b>".$_POST["user"]."</b>!</p>";
    echo "<p>Your message is:<br/><b>".$_POST["message"]."</b></p>";
?>
My result is:
Welcome ".$_POST["user"]."!

"; echo "

Your message is:
".$_POST["message"]."
"; ?>

Both files are in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs
as simpleform.html and send_simpleform.php.

Have I nimble-fingered something, or just missing some great truth...?

Re: Cannot read input from form

Posted: Mon Dec 22, 2008 3:51 pm
by califdon
It appears that either PHP isn't installed correctly or that Apache isn't configured to use PHP. Have you tried to open a PHP file that has only this in it:

Code: Select all

<?php
echo phpinfo():
?>
That should produce a very long list in the browser of settings for PHP and MySQL. If it does not, you need to check your httpd.conf file (the configuration file for Apache) to insure that it is set up for PHP. Start with that.

Re: Cannot read input from form

Posted: Mon Dec 22, 2008 4:17 pm
by sink
califdon,

Thanks for your reply. The phpinfo() echo works fine.

This what is called a PEBKAC error...Problem Exists Between Keyboard And Chair....

I double clicked on the html file in Windows Explorer to launch it instead of entering
http://localhost/simpleform.html in the browser. Not surprisingly, Apache didn't serve up the page.

I'm not always this much of an idiot. Must have been the eggnog...

Have a merry merry

Re: Cannot read input from form

Posted: Mon Dec 22, 2008 8:12 pm
by califdon
:lol: It happens! You're showing that you understand how it works, though, and that's good! Feel welcome to come back with other questions. Even after Christmas! I hope yours will be Merry, too.