Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

->why is the code showing as oposed to working???

Status
Not open for further replies.

mRko81

Programmer
Apr 25, 2006
39
US
i have a client who wants to implement a CAPTCHA verification on the forms on his website. i found the script to do this here:

i have it so it creates the image but it does not output the rest of the script instead it shows the code. here is the page i am working on:

Code:
<TR>
<TD colSpan=3 height=40>
  <div style="border: solid 1px #4f8ac4;">
    <img src="picture.php" />
  </div>
<? include("verification_image.class.php");
  $image = new verification_image();
     // do this when the form is submitted
  echo $image->validate_code($_SESSION['verification_key']) ? "true" : "false"; ?>
</TD>
</TR>

and i also have a txt file of the same page so you can see the code with out me posting the whole page here:


Please help.

Thank you in advance.
 
PHP doesn't get parsed in files with extensions other than .PHP unless the server is configured to parse files with other extensions.

Rename your file index_TEST.htm to index_TEST.[red]php[/red]



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
i have a .htaccess file that is supposed to allow php to be parsed under the htm extention, but when i changed the extention to php it shows the value of true. so apparently my .htaccess file is not functioning. Can .htaccess work on a windows server? if not is there some sort of an alternative, i do not want to have to change the extentions on all his pages (there is a contact form on every page) because i dont want to break possible bookmarks not to mention the navigation of the site.

Thank you Vacunita for your response.
 
A .htaccess file can, indeed, work on Win32. So long as you are running the Apache web server on that platform. If you're running IIS, .htaccess files are meaningless.

What web server are you using?



Want the best answers? Ask the best questions! TANSTAAFL!
 
it says windows in my control panel but i cant tell if it is running apache or what? is there a way to find out?
 
The quickest way is probably to go to a command prompt and type the following:

telnet <ip address of server> 80[enter]

then when telnet is running type:

HEAD / HTTP/1.0[enter]
[enter]


The web server should return a set of HTTP headers which includes on which begins "Server:". An Apache server will return something along the lines of:

Server: Apache/2.0.53 (Unix) mod_ssl/2.0.53 OpenSSL/0.9.7a DAV/2 PHP/5.1.6

IIS will return something like:

Server: Microsoft-IIS/6.0


That'll tell you for sure.



Want the best answers? Ask the best questions! TANSTAAFL!
 
THat is cool!

heres what i get back


Server: Microsoft-IIS/6.0
X-Powered-By: PHP/5.0.4
MicrosoftOfficeWebServer: 5.0_Pub
X-Powered-By: ASP.NET
 
That means you are running IIS hence the htaccess files do squat.

However you can disable IIS, and download and install Apache for windows, to get your htaccess files to work.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
then you are using windows on a win server 2003 box.

the way to achieve the same thing as htaccess (for this directive) is in the IIS 6 management snap in. (right click on my computer and press manage. go down to sevices and applications and the iis snap-in should be there.

right click on the relevant web site or directory and select properties (actually i think this must be done on a per web-site level).

in the Home Directory tab select Configuration

go down to the php entry and note the executable path against it.

then go up to htm and html and change the executable path to be the same as php. if they are not in the ISAPI list then add them.

restart IIS

ps. i don't know for sure, but i suspect this will break webdav for those directories if you use it (although it may be that restricting verbs to GET and POST (and maybe HEAD) may avoid this.

pps. i'd consider upgrading the php installation.
 
unfortunately i do not have rights/access to do these on the server. it is a shared server. any other thoughts or do i just need to find a different application?
 
if you go down the bulk renaming path that sleipnir214 has given you references for, the navigation and link/bookmark issue you were talking about can be resolved through the use of custom error pages or redirects (although I suspect that you will not be able to use the mod_rewrite equivalent for IIS if you do not have admin access).

or as a clunky solution you could keep an html page and use simple ajax call to populate the contacts page and/or change the form action.
 
Perhaps a more general question, but most of the PHP is being processed on this page. If only fails at the validate_code() function. If PHP wasn't being processed due to the file extension, wouldn't we expect to see all of the code displayed?
 
According to the txt file the OP linked to there is no more PHP code in that page. Except for a session_start at the beggining, which I assumed was getting output as is along with the image code..

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top