Jump to content

Can't Get Php Files To Work - Possible Web Server Issue


wongadob

Recommended Posts

OK So first of all I will describe my setup. I have a home network with one device connected directly to router via cable and all other PC's/Laptops are wireless. On my wired pc I have installed XAMPP. It is NOT a server, just a regular PC running Vista with XAMPP installed. I have set up a mySQL Database, all connects fine from my laptop. I have written some code in Excel to populate my database. All fine all tables contain the correct data. So I know my laptop can connect and talk to MySQL fine. I have written a lot of HTML code and some small amounts of java script (I am in the process of learning all of this) That all works fine. I have now moved on to start the PHP coding that will communicate with my HTML and MySQL. Simple task at the moment is to revify a username and password from a table in my database (but that is not really relevant just yet) So I put all my files in my htdocs folder within a subfolder that is called 'compliance' All runs fine from here through standard html (but I am running it by just clicking on the file in the folder so may not be coming through web server. But when it gets to my PHP file it asks if I want to load or save it. As in if it was downloading a file. So I guess this is not the right way! So I have tried to access the file via a browser from my laptop by first connecting top //Dad-pc/localhost and I get the following error Access forbidden!

New XAMPP security concept:
Access to the requested directory is only available from the local network.This setting can be configured in the file "httpd-xampp.conf". If you think this is a server error, please contact the webmaster. Error 403 dad-pc 11/03/11 13:40:05 Apache/2.2.21 (Win32) mod_ssl/2.2.21 OpenSSL/1.0.0e PHP/5.3.8 mod_perl/2.0.4 Perl/v5.10.1 Now I have had a good dig around on the internet and some suggested the firewall may be the issue, but it is not. The firewall as the port 80 open and allowed for all users. I have had a look at the httpd-xampp.conf file and it does seem to have an Allow and what looks like the IP range of the Pc's on my network. Am I just being mad. Is it possible to run PHP at all via a local PC network. Have I not set something up correctly. Please help as I seem to be going around in circles. The code I am using may also be wrong. Here is my line that calls the PHP file (sorted on Xampp/htdocs/compliance/php) note all HTML files are in the Xampp/htdocs/compliance folder.
   <form method = "post" action="php\login.php">

Out of interest all the PHP file does is this

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml"><head>  <meta http-equiv="content-type" content="text/xml; charset=utf-8" />  <title>Login</title></head><body>  <?php  $UserName = $_POST["txtUserName"];  $Password = $_POST["txtPassword"];  print "<p> Username is $UserName and the password is $Password </p>";  ?></body></html>

Link to comment
Share on other sites

BTW trying to connect to //Dad-pc/xampp also gets the above error. I say this as local host may be making it check my laptop and not Dad-pc. But as I said this also has problems. Also just //Dad-pc works fine for other directories that are just shared as in any normal network. So I can access files on Dad-pc.

Link to comment
Share on other sites

Well I have discovered my error! Doh! Nothing to do with the above, I had some comments at the top of the PHP file. They were not using the correct comment style using // instead of <!-- So therefore, I assume, it did not know it was a PHP file and tried to load it as a non code file. Grrr!

Link to comment
Share on other sites

This is now Solved - However it was nothing to do with the way I had comnmented my code. That was also infact wrong, but the reason was the htt[d-xampp.conf file needed modifying in the following way. I am adding this in case anybody has simiar issues and they know how it was resolved.

# Close XAMPP sites here<LocationMatch "^/(?i:(?:xampp|licenses|phpmyadmin|webalizer|server-status|server-info))">    Order deny,allow    Deny from all    Allow from ::1 127.0.0.0/8 \			   fc00::/7 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 \			   fe80::/10 169.254.0.0/16    ErrorDocument 403 /error/HTTP_XAMPP_FORBIDDEN.html.var</LocationMatch>

Don't ask me what any of this actually means, but I guess it is allowing access to machines on a local network. Anyway once I did this and re-booted my Webserver PC (must be done apparently) it all worked. Hope this helps solve somebody else's problem as this had me pulling my hair out for most of a day.

Link to comment
Share on other sites

I am aware that you say PHP now works, however I will explain, as you said, for others.The above snippet from the xampp configuration file is the new 'XAMPP security concept'. Basically it says:If the user is requesting a page where the URL contains any of:

  • xampp
  • licenses
  • phpmyadmin
  • webalizer
  • server-status
  • server-info

then redirect them to an error page telling them they may not visit, UNLESS they are on the local machine.When I was developing a site for my brother, I had to remove '|phpmyadmin' so I could access the database from my computer that was running on his laptop. This has nothing to do with allowing PHP files to run.If you are having problems with PHP running you must add the PHP type with the following code into your server configuration. NOTE that XAMPP comes configured already.

AddType application/x-httpd-php .php

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...