Calling captcha script from IMG tag

software development

#1

Hey, I’m trying to implement a captcha script (from http://www.white-hat-web-design.co.uk/articles/php-captcha.php), but I don’t think that the script is actually executing.

The script is being called from a straight HTML block as:

img src=“CaptchaSecurityImages.php” alt=“wtf”

and “wtf” is showing up on the page.

I added echo statements in CaptchaSecurityImages.php and they aren’t showing up on the page or in view page source either

this is the page, if anyone wantys to view page source.

http://coolgeek.dreamhosters.com/ha_feedback.php

both php scripts are in the root directory


#2

It looks like your actual script is broken. You should be able to browse directly to http://coolgeek.dreamhosters.com/CaptchaSecurityImages.php and see an example image, but you get a load of error message goodness instead. It is impossible for me to view the actual PHP, but it looks like “going to function” is being output to the browser (which will break the script). You’ll need to remove “back from function” as well.

si-blog
Max discount on any plan with promocode SCJESSEYTOTAL


#3

This might help…

going to function Warning: Cannot modify header information - headers already sent by (output started at /home/.janeane/coolgeek/coolgeek.dreamhosters.com/CaptchaSecurityImages.php:77) in /home/.janeane/coolgeek/coolgeek.dreamhosters.com/CaptchaSecurityImages.php on line 66 Check to make sure you have absolutely no white space outside of your <?php ?> tags. No spaces, no tabs, no blank lines. I learned (the hard way, of course) this can cause the above error.

Hope this helps, it is the only thing I can think of at the moment.

Regards,
Rudy


#4

Thanks scjessey (and, on preview, Rudy).

Didn’t think to try hitting the script directly…

I removed the echo statements and it is indeed working correctly now.

However, I was originally keeping the Captcha script in an include directory, outside document root, with all of my php require files:

img src="…/devinclude/CaptchaSecurityImages.php" alt=“wtf”

and that is still failing, showing the alt text

Is Apache not allowing this because it’s outside of the document root? Is there a way around this?


#5

Yes.

include("devinclude/CaptchaSecurityImages.php");I probably have a typo in the suggested path…
While the web browser can not go outside the web document root, php can.

Regards,
Rudy


#6

As long as the script is somewhere in your web folder (or some sub folder therein) you should have no problem. Just make sure everything is in the same place though (like the font file, etc.).

si-blog
Max discount on any plan with promocode SCJESSEYTOTAL


#7

okay, I put it back in doc root.

thanks all


#8

Here is the captcha http://phpsnips.com/snippet.php?id=43 that I made, and it works really nicely.


TzFiles.com