Image Captcha AJAX Refresh

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

Post Reply
User avatar
Pazuzu156
Forum Contributor
Posts: 241
Joined: Sat Nov 20, 2010 9:00 pm
Location: GA, USA
Contact:

Image Captcha AJAX Refresh

Post by Pazuzu156 »

I'm using my own captcha image i created with PHP, and When a refresh button is pressed, I want it to cycle through the characters and create another captcha image. How would I so this using jQuery's AJAX and PHP to do this without refreshing the page?
- Kaleb Klein
------------------------------------
Web Developer | Software Developer
https://kalebklein.com
PGP Key: https://keybase.io/pazuzu156
User avatar
phazorRise
Forum Contributor
Posts: 134
Joined: Mon Dec 27, 2010 7:58 am

Re: Image Captcha AJAX Refresh

Post by phazorRise »

You don't need Ajax to do this.
You can simply use-

Code: Select all

<img src="captcha_file.php?sid=<?php echo md5(time()) ?>" id="cap_img">
<a href="#"onclick="document.getElementById('cap_img').src = 'captcha_file.php?sid=' + Math.random(); return false">Refresh</a>
I use same thing on my site.
User avatar
Pazuzu156
Forum Contributor
Posts: 241
Joined: Sat Nov 20, 2010 9:00 pm
Location: GA, USA
Contact:

Re: Image Captcha AJAX Refresh

Post by Pazuzu156 »

I'll work with it some, thanks.
- Kaleb Klein
------------------------------------
Web Developer | Software Developer
https://kalebklein.com
PGP Key: https://keybase.io/pazuzu156
Post Reply