|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Need Help with file extensions
Hello. I was working with Apache, PHP and MYSQL. I had to make adjustments in the Apache config file and add some file extensions to allow php code in .html files. I have a few index.html pages that need to do a little bit of PHP code and now that I am using IIS and MYSQL and PHP, I am not sure how to set this up.
I assume this can be done. If so, where can I find the IIS config file and where should I make the changes? Thank you for any helo with this. ![]() |
|
#2
|
||||
|
||||
|
__________________
Raid1 in XP Pro My open source projects: ------------------------ Blobber - Add images as blobs to SQL Server ------------------------ |
|
#3
|
|||
|
|||
|
I appreciate the link, but I have already done this. PHP works. I can open index.php and it display fine. What I need, is to be able to execute php code in index.html. In APache config file you could add extensions that would allow this. I need to be able to do this with IIS. Can I not do this? Or do I just need to change all my index.html pages to index.php?
If that link you posted was supposed to tell me how to do this, I have done all those things and it still does not work. Thanks |
|
#4
|
||||
|
||||
|
I'm about 99% sure it has to have a .php extension for it to work. Shouldnt be difficult though, just rename them all to .php and update your links.
|
|
#5
|
|||
|
|||
|
On the mappings page make sure .html files map to c:\php\php.exe (or wherever your php executable is). But this will put quite an additional load on your web server since all html pages will run through the php interpreter before being output to the web browser.
I'd probably change the file extensions to .php instead.
__________________
====== Doug G ====== "Hide, hide witch! The good folk come to burn thee. Their keen enjoyment hid behind their gothic mask of duty." -Mark Clifton |
|
#6
|
|||
|
|||
|
OK, I renamed the index.html file to index.php and I still see php code when I execute the page. I can take the same code and paste it into a test page on another server running apache and it works fine.
I do have index.html as well as index.php added to the default documents in the IIS admin section. I tried adding php to the ISAPI filters list and pointed it to the php.exe and it has a red down arrow beside it and the status is "Not Loaded". I read some where to point this filter to the php4isapi.dll and I tried it as well with the same results. At this point, I can load a php test page that shows phpinfo(). And it looks fine. But when I try to load my index page, I get html mixed with php code. Like I said, I can copy this exact code into a test file on an apache server and it works and looks fine. Any ideas? I am at a loss here as to what to do next. Thanks for any help. |
|
#7
|
|||
|
|||
|
Make sure the web server has script execute permissions on the files and folders. If you see the code in your browser that is a sign that the php code is not getting sent through the php parser for some reason.
|
|
#8
|
|||
|
|||
|
Thanks for the reply. I have all my website sites in the wwwroot dir. THe same dir as the test.php file that executes the phpinfo() script correctly. Not sure what I should do differently here by what you are saying. Can you please elaborate as to why one file would execute php in the same dir as another but the other file does not?
THank you again |
|
#9
|
|||
|
|||
|
Maybe there is a problem in your php page code.
|
|
#10
|
|||
|
|||
|
Yes, but like I said earlier, I can take this page that is showing the php code in the browser and copy it up to another server (running apache) and it works fine. SO it is not the code on the page.
Thanks for the reply. Anyone else have any suggestions? |
|
#11
|
||||
|
||||
|
Maybe theres something in the code that IIS doesnt recognize, but Apache does. Post it here with the error message and we'll look at it.
|
|
#12
|
|||
|
|||
|
Ok, this page has no errors, it just shows a few fragments of php code, not even all of it...All this page is, is a login and if the user is logged in already, (I use sess vars to check) I forward them on to a different page using the page include.
When I view the page in the browser I see "; echo $value;}?> No errors at all and like I said earlier, I can call my test.php page that has an echo as well as phpinfo() in the same location on my server and it runs fine. Code:
<?
session_start();
//here we unregister our sess vars if the user hit logout.
if (!empty($_GET["logout"]))
{
$HTTP_SESSION_VARS["group"] = '';
$HTTP_SESSION_VARS["userid"] = '';
session_destroy();
session_unregister("group");
session_unregister("userid");
}
if (!empty($HTTP_SESSION_VARS["group"]) && !empty($HTTP_SESSION_VARS["userid"]))
include ("main/access.php");
//we enter here if it is the first time logging in and no session vars have been set yet.
else
{
include("functions.php");
$value = "<html>
<head>
<title> MUMS Major Unit Management System </title>
<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">
<link rel=\"stylesheet\" type=\"text/css\" href=\"main.css\">
</HEAD>
<SCRIPT LANGUAGE=\"JavaScript\">
function TheFormCheck()
{
if (document.login.username.value == \"\" || document.login.password.value == \"\")
{
alert(\"You must fill in a UserName and Password to continue.\");
document.login.username.focus();
return false;
}
else
return true;
}
</script>
<SCRIPT LANGUAGE=\"JavaScript\">
<!-- Original: Tom Khoury (twaks@yahoo.com) -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
function placeFocus()
{
if (document.forms.length > 0)
{
var field = document.forms[0];
for (i = 0; i < field.length; i++)
{
if ((field.elements[i].type == \"text\") ||
(field.elements[i].type == \"textarea\") ||
(field.elements[i].type.toString().charAt(0) ==\"s\"))
{
document.forms[0].elements[i].focus();
break;
}
}
}
}
// End -->
</script>
<!--this is for our onfocus field colors-->
<script type=\"text/javascript\" language=\"JavaScript\" src=\"main/code.js\"></script>
<BODY topmargin=\"0\" marginwidth=\"0\" leftmargin=\"0\" hspace=\"0\" bgcolor=\"#ffffff\" OnLoad=\"placeFocus();\">
<form name=\"login\" action=\"main/access.php\" method=\"post\" onSubmit=\"return TheFormCheck()\">
<table border=0 width=275 align=center>
<tr>
<td colspan=2>
To gain access into MUMS, you must provide a UserName and Password.
</td>
</tr>
<tr>
<td width=20%>
UserName
</td>
<td>
<input type=text name=username size=15 maxlength=15 value=\"\" onFocus=\"chgit(this)\" onBlur=\"chgback(this)\">
</td>
</tr>
<tr>
<td width=20%>
Password
</td>
<td>
<input type=password name=password size=15 maxlength=15 value=\"\" onFocus=\"chgit(this)\" onBlur=\"chgback(this)\">
</td>
</tr>
</table>
<table width=300 align=center>
<tr>
<td align=right>
<input type=submit name=submit value=\"Login\">
</td>
</tr>
</table></form>
</body>
</html>";
echo $value;
}
?>
Sorry about the formatting, my editor seems to add extra spaces... Thanks for any help |
|
#13
|
|||
|
|||
|
Quote:
This indicates there is a code problem, php thinks the lines you see are html code rather than php. A misplaced " or ; may cause this kind of problem. |