PHP displaying source code......

Problems with the Windows version of XAMPP, questions, comments, and anything related.

PHP displaying source code......

Postby dkperez » 29. September 2009 15:49

Just for a change, BEFORE I go in hacking away at configurations and such, I figured I'd look in here for what's going on... I did a couple searches and got back a ton of hits, but apparently I'm not doing it quite right 'cause one of them told me what I need to do... Installed xampp-win32-1.7.2 because I was having an impossible time getting separate php, apache, and mysql working (actually, so far, the whole php/mysql thing has been an absolute nightmare)... It says the installation is successful.

The Status says things have been activated - mysql, php, apache, etc.......

phpinfo shows php information. Apache 2.2 service is running. Doing "localhost" brings up the xampp page. Things APPEAR to be good.......

SO, I have a trivially simple html file:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test html</title>
</head>
<body>
<h2>html title</h2>

<p>Simple html form:</p>
<form method="post" action="report.php">
<input type="submit" value="testbutton" name="submit" />
</form>
</body>
</html>


That calls a trivially simple php file:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>html title in php file</title>
</head>
<body>
<h2>html header in php file</h2>

<?php

echo 'Submitting pressed - displaying php';
?>

</body>
</html>

I run it by double-clicking on the html file (both of which are in the htdocs directory)... Comes up fine with the screen and button.
But, when I push the button, one of two things happens, and I have no idea what causes which:

I either get the source code for the php file instead of having it run
OR I get NOTHING from the php.... The "h2" header displays "html header in php file" and I get nothing afterward.....

I know this has to be a simple configuration thing, and I'm going to head out on the Internet to look at topics in other places that talk about getting php source code, but I figured
I'd at least ask in here since y'all would be the experts on xampp and its components......
dkperez
 
Posts: 2
Joined: 29. September 2009 15:36

Re: PHP displaying source code......

Postby Wiedmann » 29. September 2009 16:14

I run it by double-clicking

You have installed a webserver with XAMPP. So please use "http://..." in your browser and don't double-click on a file.
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: PHP displaying source code......

Postby dkperez » 29. September 2009 21:11

OK, now THAT's just embarrasing...........

thanks for the quick answer...........

I have a feeling this may have been part of the problem with my separate installations too, but since I've got XAMPP on now, I'll just use this........

Good grief. Somewhere in the HeadsUpPHP book you'd think they'd have put a BIG note that says "DON'T DOUBLE-CLICK THE HTML FILE"!!
dkperez
 
Posts: 2
Joined: 29. September 2009 15:36


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 44 guests