PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
bwv2
Forum Commoner
Posts: 83 Joined: Fri Jun 10, 2005 11:50 am
Location: AZ
Post
by bwv2 » Wed May 03, 2006 2:46 pm
I have just changed my main page from index.php to index.html. In the process I had a bunch of stuff changed in the code to make it ready for the public domain, but now my embedded PHP code doesn't work.
I was under the impression that PHP could be integrated by simply using the <? ?> insertion tags in html documents. Here's an example of my page. Note that the <? session_start()?> doesn't work, and neither does the $_SESSION call in the signin box.
Code: Select all
<? session_start();?>
<html>
<head>
<title>The Page</title>
<meta http-equiv="Content-Type" content="text/html;">
.
.
.
<table ALIGN="CENTER" BORDER=0 id="text">
<form name="theForm" action="./sheets/getin.php" method="POST">
<TR><TD><h3>Sign In</h3></TD></TR>
<tr><td>Username:</td><td><input type="text" name="username" value="
<? if(!empty($_SESSION['username'])){
echo $_SESSION['username'];
}else echo "";
?>"></td></tr>
<tr><td>Password:</td><td><input type="password" name="password"></td></tr>
<tr><td><input type="submit" value="login" name="submit"></td></tr>
</form>
</table>
Any ideas?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed May 03, 2006 2:52 pm
php probably doesn't know you want to process .html files as a php file. Depending on your web server, this could be a change in the control panel, a change of the httpd.conf or some other area.
Oren
DevNet Resident
Posts: 1640 Joined: Fri Apr 07, 2006 5:13 am
Location: Israel
Post
by Oren » Wed May 03, 2006 2:53 pm
bwv2 wrote: I was under the impression that PHP could be integrated by simply using the <? ?> insertion tags in html documents.
That's wrong.
You can set your server to treat HTML files as PHP though.
Ollie Saunders
DevNet Master
Posts: 3179 Joined: Tue May 24, 2005 6:01 pm
Location: UK
Post
by Ollie Saunders » Wed May 03, 2006 6:20 pm
Oren wrote: bwv2 wrote: I was under the impression that PHP could be integrated by simply using the <? ?> insertion tags in html documents.
That's wrong.
You can set your server to treat HTML files as PHP though.
I wouldn't say its wrong. You just have to have your server configured correctly.
someberry
Forum Contributor
Posts: 172 Joined: Mon Apr 11, 2005 5:16 am
Post
by someberry » Thu May 04, 2006 2:48 am
You need to inform Apache (I assume you are using Apache) that you want .html files parsed as PHP. Add this to your .htaccess file:
Code: Select all
AddType application/x-httpd-php .html
If you want to add more extentions to be parsed as PHP, then do this:
Code: Select all
AddType application/x-httpd-php .html .htm .css .png
Oren
DevNet Resident
Posts: 1640 Joined: Fri Apr 07, 2006 5:13 am
Location: Israel
Post
by Oren » Thu May 04, 2006 2:58 am
ole wrote: Oren wrote: bwv2 wrote: I was under the impression that PHP could be integrated by simply using the <? ?> insertion tags in html documents.
That's wrong.
You can set your server to treat HTML files as PHP though.
I wouldn't say its wrong. You just have to have your server configured correctly.
Well... Didn't I mention that?!
Ollie Saunders
DevNet Master
Posts: 3179 Joined: Tue May 24, 2005 6:01 pm
Location: UK
Post
by Ollie Saunders » Thu May 04, 2006 3:38 am
Well... Didn't I mention that?!
Err yeah sorry I read it out of context
Oren
DevNet Resident
Posts: 1640 Joined: Fri Apr 07, 2006 5:13 am
Location: Israel
Post
by Oren » Thu May 04, 2006 3:43 am
That's ok
bwv2
Forum Commoner
Posts: 83 Joined: Fri Jun 10, 2005 11:50 am
Location: AZ
Post
by bwv2 » Thu May 04, 2006 9:20 am
Okay, so how would I go about changing my server settings to allow php in html? Is it something in the php.ini file?
vincenzobar
Forum Commoner
Posts: 95 Joined: Wed Nov 02, 2005 9:57 am
Post
by vincenzobar » Thu May 04, 2006 9:34 am
ass mentioned above you have to allow HTM or HTML to read as php in your .htaccess file or in httpd.conf
Also make sure your server allows users to use htaccess in your httpd.conf
Code: Select all
Options +FollowSymLinks
RewriteEngine on
AddType application/x-httpd-php .html .htm