Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Apache 2 with php5 - server-side scripts not recognized |
|
Author |
|
djbranson
Joined: 22 Oct 2006 Posts: 8 Location: Lubbock, Texas
|
Posted: Sat 28 Oct '06 16:02 Post subject: Apache 2 with php5 - server-side scripts not recognized |
|
|
I have installed Apache 2.2.3 with php 5.1.6 on Windows XP SP2. Client-side php scripts seem to work okay when called from my browser, but when I call a server-side php script from html, it simply displays the php script's source code in the browser window. The server-side php script I am testing with html is:
<?php
$to = "test@mydomain.com";
$subject = "Test Contact Form";
$email = $_REQUEST['email'];
$message = $_REQUEST['message'];
$headers = "From: $email";
$sent = mail($to, $subject, $message, $headers);
if($sent)
{print "The mail was sent";}
else
{print "An error was encountered with the mail";" ";$email;" ";$subject;" ";$message;" ";$headers}
?>
The html that calls it is:
<html>
<head>
<title>Contact Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form name="contacts" method="post" action="contact_test.php">
Email: <input name="email" type="text"><br>
Message:<br>
<textarea name="message" rows="15"
cols="40"></textarea><br>
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>
Any help would be appreciated. |
|
Back to top |
|
admin Site Admin
Joined: 15 Oct 2005 Posts: 692
|
Posted: Sat 28 Oct '06 17:08 Post subject: |
|
|
You said: "... Client-side php scripts seem to work okay...".
Seems ? Be sure that it is working.
Tried the following and it works fine here:
<?php
$to = "test@mydomain.com";
$subject = "Test Contact Form";
$email = $_REQUEST['email'];
$message = $_REQUEST['message'];
$headers = "From: $email";
$sent = mail($to, $subject, $message, $headers);
if($sent)
echo ("The mail was sent");
else
echo ("An error was encountered with the mail");
?> |
|
Back to top |
|
djbranson
Joined: 22 Oct 2006 Posts: 8 Location: Lubbock, Texas
|
Posted: Sat 28 Oct '06 18:06 Post subject: Seems to... |
|
|
The client-side script I called directly from my browser's command line is:
<?php
echo "This is a php5 client-side test!<br>\n";
phpinfo();
?>
This displayed the sentence above, plus several pages of tabular php information. I have not performed any other tests to verify that the client-side of php is working.
I ran the script you provided, and got the same result - the script echoed in the browser. Do you have any ideas as to what I should do from here? |
|
Back to top |
|
Steffen Moderator
Joined: 15 Oct 2005 Posts: 3092 Location: Hilversum, NL, EU
|
Posted: Sat 28 Oct '06 18:10 Post subject: |
|
|
Where did you download Apache ?
and what changes you made in you httpd.conf ? |
|
Back to top |
|
djbranson
Joined: 22 Oct 2006 Posts: 8 Location: Lubbock, Texas
|
Posted: Sat 28 Oct '06 18:56 Post subject: |
|
|
I followed the "Apache and PHP - A Fast, Reliable, and Proven Setup" post to download and set up Apache, PHP5, and your Microsoft VC++ build, and to edit httpd.conf and Apache2/conf/extra/httpd-userdir.conf (these varied slightly from the written steps, as httpd-userdir.conf was a separate file in the current distribution of Apache 2.2.3).
In httpd.conf I edited to add/change:
LoadModule php5_module "c:/PHP5/php5apache2.dll"
AddHandler application/x-httpd-php .php
PHPIniDir "c:/PHP5"
ServerAdmin me@mydomain.com
DocumentRoot "c:/Documents and Settings/.../My Documents/My Website/localhost/www"
<Directory "c:/Documents and Settings/.../My Documents/My Website/localhost/www">
ScriptAlias /cgi-bin/ "c:/Documents and Settings/.../My Documents/My Website/localhost/cgi/"
<Directory "c:/Documents and Settings/.../My Documents/My Website/localhost/cgi">
AddType application/x-httpd-php .php
AddHandler cgi-script .cgi
Include conf/extra/httpd-userdir.conf
In httpd-userdir.conf I edited to add/change:
UserDir "My Documents/My Website"
<Directory "c:/Documents and Settings/.../My Documents/My Website/localhost">
Options MultiViews Indexes SymLinksIfOwnerMatch Includes ExecCGI
I also made a change to the PATH environmental variable to include c:\PHP5. I think that covers the changes I made. |
|
Back to top |
|
Steffen Moderator
Joined: 15 Oct 2005 Posts: 3092 Location: Hilversum, NL, EU
|
|
Back to top |
|
djbranson
Joined: 22 Oct 2006 Posts: 8 Location: Lubbock, Texas
|
Posted: Sat 28 Oct '06 22:00 Post subject: tried it, but no-go |
|
|
I have commented out the "Include httpd-userdir.conf", but still have the same problem. It seems like the browser sees server-side PHP scripts as text. Do browsers typically display bad code as text? If not, then I think this problem may not be in the scripts or the Apache/PHP installation. Do you know what should show up in the Windows registry related to these installations? |
|
Back to top |
|
Steffen Moderator
Joined: 15 Oct 2005 Posts: 3092 Location: Hilversum, NL, EU
|
Posted: Sat 28 Oct '06 22:18 Post subject: |
|
|
Maybe you can send me the link ( the contact link at the left top menu), so I can see if it is browser related.
For Apache there is nothing in the register what it needs, only whhen you install it as a service.
Steffen |
|
Back to top |
|
|
|
|
|
|