New and need help

I have only been learning PHP for about a week now and bought the Sam’s teach yourself PHP, MySQL, and Apache All in One deal from the book store to start me out.

I think I have understood it pretty well, or at least as well as I can in the first week, but I have run into some trouble.

I have no problems writing the code for the simple functions, they are displayed like they are suppose to be in the browser, my trouble is when I am making a simple HTML form and a simple UPLOAD deal in HTML and I call on the php file, all that is printed on the screen is the ACTUAL php code… it doesnt perform the PHP file for me.

They are both located in the root directory, and it seems simple enough to me, but for some reason it just isn’t doing what it is suppose to do.

HERE IS THE HTML FORM:

<html>
<head>
<title>A Simple HTML Input 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>

AND THIS READS JUST FINE IN THE BROWSER

HERE IS THE PHP FILE:
[php]

<?php echo "

Welcome ".$_POST["user"]."!

"; echo "

Your message is:
".$_POST["message"]."

"; ?>

[/php]

This all seems so cut and dry!
ANY help would be huge right now so I can move on.
Thanks for all your help in advance!

–Rick

Admin edit: Added [code] and [php] tags for readability. Please refer to http://phphelp.com/guidelines.php for posting guidelines

Without looking at the code you posted (which should be between [code] or [php] tags, mind you), it sounds like your PHP file isn’t being executed. Dumb question, but did you give it the .php extension?

Yes, it does have the .php extension.

It seems like I have checked and double checked the whole deal, but still nothing.

Not sure if it will make a difference, but try changing the DOUBLE quotes in the POST array index to SINGLE quotes.

[php]

<?php echo "

Welcome ".$_POST['user']."!

"; echo "

Your message is:
".$_POST['message']."

"; ?>

[/php]

also just to make sure that the PHP file is called send_simpleform.php

changed it and it didn’t help.
The whole code still gets displayed through my browser.

I have two codes that I am working on.
The first is a simple form that just displays text in the browser and the second is an upload form…

Both do the same thing, so whatever it is that I am doing wrong is following me!

So when you POST the form to send_simpleform.php only the code for the page is displayed (i.e. plain text)?

If this is the case… PHP is not running.

To verify this you could create a file called phpinfo.php in the root of your webserver. In that file put the following:

[php]

<? phpinfo(); ?>

[/php]
save it. Then pull it up in a browser ( http://yourdomain.com/phpinfo.php ). You should see a whole lot of information about your PHP installation and webserver. If you don’t then you are probably not running php.

That was the first thing I did when I first started running this. All of my other php files come up just fine.

It’s only the HTML forms that I am having trouble with.

But, yeah, it comes up into the browser as plain text… I dont get it.

so you say the phpinfo.php page comes up as plain text?

If so, then your php is not running.

if your other phps are running then it cant be that php is not running…

Double check everything, where you put your files, and your permissions.

It will probably be something very simple that your brain isnt seeing because its so simple.

It happened to me a couple days ago trying to figure something out with getting a day name from a date. Then once i wasn’t thinking about it, it all came to me.

if your other phps are running then it cant be that php is not running..

Semi-Dangerous phrase here… Define running… as Paul has pointed out what do they mean comes out as plain text.

When you run a phpinfo page and have phpinfo() in the page you shouldn’t just get a -

phpinfo() to display. You should get a big long list of information about your webserver and php information. (As paul already previous stated)

So I guess the question to be answer first off is - when you run a phpinfo page. Did you get all this information or what did you get?

It may also be that PHP is running perfectly, but your webserver software doesn’t know what to do with it - and does the default thing: output it as plain HTML. So, which server software are you running, and did you configure it to run .php pages as, well, PHP scripts?

When I post the phpinfo.php I get all of the info as I should.
When I post ANY other simple php file that I am learning to do, it comes up as it should… it follows the commands and such.

However, when I do any type of HTML form that points to a php file, what is displayed in the browser is the actual HTML code… does this make more sence?

is there a URL that you could point us to so that we can see?

And perhaps you could also post the PHP code here as well.

Sponsor our Newsletter | Privacy Policy | Terms of Service