Cannot read input from form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sink
Forum Newbie
Posts: 3
Joined: Mon Dec 22, 2008 2:59 pm

Cannot read input from form

Post 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...?
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Cannot read input from form

Post 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.
sink
Forum Newbie
Posts: 3
Joined: Mon Dec 22, 2008 2:59 pm

Re: Cannot read input from form

Post 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
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Cannot read input from form

Post 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.
Post Reply