Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP/Apache problems

Status
Not open for further replies.

THE4MAN

Technical User
Mar 17, 2002
73
US
Help!

I'm using Dreamweaver MX to create a couple of PHP test pages. Just wanting to input a name and have it say thank you, "name" on a second page. Really easy stuff, I know, but here's what happens...

I get the first page (test_form.php) authored correctly with the following code:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<title>Test Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>

<body>
<form name="frm_name" id="frm_name" method="post" action="test_form_processor.php">
  First Name 
  <input name="firstName" type="text" id="firstName" />
  <input type="submit" name="Submit" value="Submit" />
</form>
</body>
</html>

Then I create the second page (test_form_processor.php) with the following code:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>

<body>

<p>Thank you, <?php echo $_POST['firstName']; ?>, for filling out my form. </p>
</body>
</html>

When I run the first page, I get the prompt to enter the name. I do and click the button. The second page that is displayed omits the name I entered on the first page(displaying nothing in it's place). The source code for the 2nd page, instead of displaying the name in HTML, shows the actual PHP code: <?php echo $_POST['firstName']; ?>

Here's the other important stuff. I successfully installed Apache 2.0.50 and PHP 4.3.8. I get the Apache screen at and I get the PHP info screen when I execute a phpinfo file in the localhost folder. So both would appear to be running correctly. This is on a Win2000 Pro machine with SP4 installed.

What's going on here? Is Apache not processing PHP correctly? Or is PHP not configured correctly to work with Apache? Or something else altogether?

Thanks in advance for any help you can provide.

Dave Fore
 
Several things...

You should not name your submit button like you have. Should you ever need to attempt to submit the form using Javascript then it will fail.

Change
Code:
<input type="submit" name="Submit" value="Submit" />

To this
Code:
<input type="submit" name="SubmitButton" value="Submit" />

But that is not the real problem. Because you are actually seeing the text "<?php ..." on your rendered page, then it immediately says to me that the PHP code on that page is not being processed.

Usually the solution is simple - name the php file with a .php file extension... but you have already done this (the file name on the form action from page 1 shows this).

I can only pick that PHP is not set up/configured correctly.

Suggest that you post to the PHP forum with this in mind... they can solve this kind of thing with their eyes closed :)

All the best,
Jeff
 
this bit is wrong for a PHP page

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]

you need to use

Code:
<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]

and yeah, your server must be not processing the pages.

Sometimes, when my code just won't behave, I take it outside and make it listen to britney spears music, and when it comes back it's really well behaved. I wonder if it's suffering from post tramatic stress syndrome now..
 
DaRNCaT - The only difference between your 'before' and 'after' code examples is the xml declaration that you've added. This isn't needed (although I agree it's useful to have). This won't fix the THE4MAN's problem.

Note: php has a choice of 2 modes: short tags or long tags.

If you use short tags, anything between <? and ?> is processed by the PHP parser.
This can cause problems with an xml declaration - such as:
[tt]<?xml version="1.0" encoding="iso-8859-1"?>[/tt]
This is why - with short tags - you issue a php command to echo the xml declaration:
[tt]<?php echo('<?xml version="1.0" encoding="iso-8859-1"?>'); ?>[/tt]

In long-tags mode, php only interprets tags between <?php and ?>.


I go with the consensus: either your file is named incorrectly (e.g. 'x.html' instead of 'x.php') or your php config isn't correct.

<marc> i wonder what will happen if i press this...[ul][li]please tell us if our suggestion has helped[/li][li]need some help? faq581-3339[/li][/ul]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top