473,467 Members | 1,398 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

cant refresh captcha image

18 New Member
hi

i m using IE 6.0.
i want to refresh just the captcha part when the user clicks on an image.

i searched for articles on it and got a fairly good understanding of it.
but i m still unable to get any results.

i have used Simple AJAX Code-Kit (SACK) (http://www.twilightuniverse.com/)

my code:

head part:::



Expand|Select|Wrap|Line Numbers
  1. <head>
  2.  
  3. <script type="text/javascript" src="ajax.js"></script> 
  4. // i have saved ajax.js in my common website folder which contains all the files  
  5.  
  6. <script type="text/javascript">
  7.  
  8. var ajax = new sack();
  9. var contentObj;
  10.  
  11. function showContent()    
  12. {
  13.     contentObj.innerHTML = ajax.response;    
  14. }
  15.  
  16.  
  17. function showWaitMessage()
  18. {
  19.     contentObj.innerHTML = 'Loading image...Please wait';
  20.  
  21. }
  22.  
  23. function getAjaxFile(fileName)
  24. {
  25.     ajax.requestFile = fileName;    
  26.     ajax.onCompletion = showContent;
  27.     ajax.onLoading = showWaitMessage;
  28.     ajax.runAJAX();    
  29. }
  30.  
  31.  
  32.  
  33. function captcha()
  34. {
  35.     getAjaxFile(captcha.php);    
  36. }
  37.  
  38.  
  39.  
  40. function initAjaxDemo()
  41. {
  42.     contentObj = document.getElementById('div_captcha');
  43. }
  44.  
  45.  
  46. window.onload = initAjaxDemo;
  47.  
  48. </script>
  49. </head>
  50.  
-------------------------

body part:::::


Expand|Select|Wrap|Line Numbers
  1. <div id="div_captcha">
  2. default text
  3. </div>
  4.  
  5. <img alt="Request new image" src="req_im.gif" onclick="captcha()">

but the script is not working
and it is not loading the contents of captcha.php on clicking on the image.

please help
Oct 21 '07 #1
7 10125
acoder
16,027 Recognized Expert Moderator MVP
What does captcha.php return?
Oct 22 '07 #2
mitchell
18 New Member
does the captcha.php have to return something
can you please elaborate on that.
i thought it can be just a simple file

contents of captcha.php::
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.  
  3. var string='';
  4. var i;
  5. var chars = 
  6.  
  7. "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
  8. var ran_unrounded;
  9. var ran_number; 
  10. var rnum;
  11. for(i=0;i<5;i++)
  12. {    
  13.  
  14.  
  15.  
  16.     rnum= Math.floor(Math.random() * chars.length);
  17.     string += chars.substring(rnum,rnum+1);
  18.  
  19.     ran_unrounded=Math.random()*3;
  20.     ran_number=Math.floor(ran_unrounded); 
  21.     document.write(chars.substring(rnum,rnum+1));
  22.  
  23. }
  24.  
  25. </script>
please help...!!!
Oct 22 '07 #3
acoder
16,027 Recognized Expert Moderator MVP
does the captcha.php have to return something
can you please elaborate on that.
i thought it can be just a simple file
Sorry, that's what I meant. It should echo something. If you run the file on its own, it should display the captcha characters on screen.

Why are you using JavaScript to generate this when it's a PHP file, but that's a side issue.
Oct 22 '07 #4
mitchell
18 New Member
i have changedn the contents of captcha.php
i have not done the whole thing
but i m just generating random nos. right now
this file when executed displays the random nos.
but it is still not showing up inside the div tag

contents of captcha.php


[PHP]<?php

srand(time());

for($i=0;$i<5;$i++)
{
$string=(rand()%6);
echo $string;


}

?>
[/PHP]
i cant find any error in the code
then whats happening????
please help
Oct 22 '07 #5
acoder
16,027 Recognized Expert Moderator MVP
So do you get any error messages?

Does the wait message show up?
Oct 23 '07 #6
mitchell
18 New Member
there r no error messages
but in the status bar of Internet Explorer it shows error on page.

i m sending the whole file now.

if u can spare time to look at it.
i will be really grateful
i have made the relevant section bold.
//register.php
[HTML]<html>
<head>

<script type="text/javascript" src="ajax.js"></script>

[/HTML]
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.  
  3. var ajax = new sack();
  4. var contentObj;
  5.  
  6.  
  7. function showContent()    
  8. {
  9.  
  10.       contentObj.innerHTML = ajax.response;    
  11.  
  12. }
  13.  
  14.  
  15. function showWaitMessage()
  16. {
  17.     contentObj.innerHTML = 'Finding article.....<br>Please wait';
  18.  
  19. }
  20.  
  21. function getAjaxFile(fileName)
  22. {
  23.     ajax.requestFile = fileName;    
  24.     ajax.onCompletion = showContent;
  25.     ajax.onLoading = showWaitMessage;
  26.     ajax.runAJAX();    
  27. }
  28.  
  29.  
  30.  
  31. function CAPTCHA()
  32. {
  33.     getAjaxFile(captcha.php);    
  34. }
  35.  
  36.  
  37.  
  38. function initAjaxDemo()
  39. {
  40.     contentObj = document.getElementById('div_captcha');
  41. }
  42.  
  43.  
  44. window.onload = initAjaxDemo;
  45.  
  46. </script>


Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. function validate_form(thisform)
  3. {
  4.     var check=true;
  5.     with (thisform)
  6.     {       
  7.         with (email)
  8.         {
  9.  
  10.             if (value==null||value=="")
  11.               {     
  12.                 document.getElementById('div_email').style.display="block";
  13.                 document.getElementById('div_email').innerHTML="<font color='red'>Username Required</font>";
  14.                 check=false;
  15.             }
  16.             else   
  17.             {
  18.                 document.getElementById('div_email').style.display="none";
  19.             }
  20.         }
  21.  
  22.         with (password)
  23.         {
  24.  
  25.             if (value==null||value=="")
  26.               {    document.getElementById('div_password').style.display="block";
  27.                 document.getElementById('div_password').innerHTML="<font color='red'>Password             
  28.  
  29.                 Required</font>";
  30.                 check=false;
  31.             }
  32.             else   
  33.             {
  34.                 document.getElementById('div_password').style.display="none";
  35.             }
  36.         }
  37.  
  38.         with (repassword)
  39.         {
  40.  
  41.             if (value==null||value=="")
  42.               {    document.getElementById('div_repassword').style.display="block";
  43.                 document.getElementById('div_repassword').innerHTML="<font color='red'>Password         
  44.  
  45.                 Required</font>";
  46.                 check=false;
  47.             }
  48.             else if(value!=password.value)
  49.             {    document.getElementById('div_repassword').style.display="block";
  50.                 document.getElementById('div_repassword').innerHTML="<font color='red'>Passwords don't match    
  51.  
  52.                 </font>";
  53.                 check=false;    
  54.             }
  55.  
  56.             else   
  57.             {
  58.                 document.getElementById('div_repassword').style.display="none";
  59.             }
  60.  
  61.         }
  62.  
  63.  
  64.         with (securityq)
  65.         {
  66.  
  67.             if (value==null||value=="")
  68.               {    document.getElementById('div_securityq').style.display="block";
  69.                 document.getElementById('div_securityq').innerHTML="<font color='red'>Security question     
  70.  
  71.             Required</font>";
  72.                 check=false;
  73.             }
  74.             else   
  75.             {
  76.                 document.getElementById('div_securityq').style.display="none";
  77.             }
  78.  
  79.         }
  80.  
  81.  
  82.         with (securitya)
  83.         {
  84.  
  85.             if (value==null||value=="")
  86.               {    document.getElementById('div_securitya').style.display="block";
  87.                 document.getElementById('div_securitya').innerHTML="<font color='red'>Security answer         
  88.  
  89.             Required</font>";
  90.                 check=false;
  91.             }
  92.             else   
  93.             {
  94.                 document.getElementById('div_securitya').style.display="none";
  95.             }
  96.  
  97.         }
  98.  
  99.  
  100.         if (months.value=="MM"||days.value=="DD"||years.value=="YYYY")
  101.         {    
  102.             document.getElementById('div_dob').style.display="block";
  103.             document.getElementById('div_dob').innerHTML="<font color='red'>Date Of Birth                
  104.  
  105.         Required</font>";
  106.             check=false;
  107.         }
  108.         else   
  109.         {
  110.             document.getElementById('div_dob').style.display="none";
  111.         }
  112.  
  113.         if (gender[0].checked==false)
  114.         {    
  115.             if(gender[1].checked==false)
  116.               {    document.getElementById('div_gender').style.display="block";
  117.                 document.getElementById('div_gender').innerHTML="<font color='red'>Gender            
  118.  
  119.             Required</font>";
  120.                 check=false;
  121.             }
  122.             else   
  123.             {
  124.                 document.getElementById('div_gender').style.display="none";
  125.             }
  126.  
  127.         }
  128.         else   
  129.         {
  130.             document.getElementById('div_gender').style.display="none";
  131.  
  132.         }
  133.  
  134.         with (visual)
  135.         {
  136.             var uppervalue=value.toUpperCase();
  137.             if (value==null||value=="")
  138.               {    document.getElementById('div_visual').style.display="block";
  139.                 document.getElementById('div_visual').innerHTML="<font color='red'>Text field needs to be     
  140.  
  141.             filled</font>";
  142.                 check=false;
  143.             }
  144.             else if (uppervalue!=string.toUpperCase())
  145.               {    document.getElementById('div_visual').style.display="block";
  146.                 document.getElementById('div_visual').innerHTML="<font color='red'>String didn't         
  147.  
  148.         match</font>";
  149.                 check=false;
  150.             }
  151.             else   
  152.             {
  153.                 document.getElementById('div_visual').style.display="none";
  154.             }
  155.  
  156.         }                
  157.  
  158.  
  159.  
  160.     }
  161.  
  162.  
  163. return check;
  164. }
Expand|Select|Wrap|Line Numbers
  1. function agreeTerms()
  2. {
  3.  
  4.     if(document.form1.terms.checked == true)
  5.     { 
  6.         document.getElementById('div_terms').style.display="none";                                  
  7.  
  8.   document.form1.register.disabled = false;
  9.  
  10.     }
  11.  
  12.     if(document.form1.terms.checked == false)
  13.     { 
  14.             document.getElementById('div_terms').style.display="block";
  15.             document.getElementById('div_terms').innerHTML="<font color='red'>You need to agree to have a <font     
  16.  
  17.             color='white'> Web<font color='orange'>mail</font></font> account </font>";        
  18.             document.form1.register.disabled = true;
  19.     }
  20.  
  21. }
  22. </script>
  23.  
[HTML]</head>

<body bgcolor="black" text="white" vlink="black" alink="black">

<table width="1230" border="2" cellspacing="0" cellpadding="0" align="center" name="header" background="bg_header.jpg">
<tr>
<td><img src="top.jpg"></td>
</tr>
</table>

<font color="white">
<br><br><br>
<div align="center">
Fields marked with asterisk(*) are compulsary.
</div>


<table align="center">
<form name="form1" id="form1" action="http://localhost/website/reg-com.php" method="post" onsubmit="return validate_form

(this)" >

<tr>
<td align="right" valign="bottom"><font color="white">Username *</font></td>
<td><div name="div_email" id="div_email"></div><input type="text" name="email" id="email" maxlength="15">
</td>
</tr>

<tr>
<td align="right" valign="bottom"><font color="white">Password *</font></td>
<td><div name="div_password" id="div_password"></div><input type="password" name="password" id="password"

maxlength="15"></td>
</tr>

<tr>
<td align="right" valign="bottom"><font color="white">Retype Password *</font></td>
<td><div name="div_repassword" id="div_repassword"></div><input type="password" name="repassword" id="repassword"

maxlength="15"></td>
</tr>

<tr>
<td align="right" valign="bottom"><font color="white">Enter your Security Question*</font></td>
<td><div name="div_securityq" id="div_securityq"></div><input type="text" name="securityq" id="securityq" size="40"

maxlength="25">&nbsp;?
</td>
</tr>

<tr>
<td align="right" valign="bottom"><font color="white">Enter your Security Answer*</font></td>
<td><div name="div_securitya" id="div_securitya"></div><input type="text" name="securitya" id="securitya" size="10"

maxlength="10">
</td>
</tr>


<tr>
<td align="right" valign="bottom"><font color="white">Date of Birth *</font></td>[/html]
[html]<td>
<div name="div_dob" id="div_dob"></div>
<select name="months">
<option value="MM" selected="selected">MM</option>
<option label="Jan" value="01">Jan</option>
<option label="Feb" value="02">Feb</option>
<option label="Mar" value="03">Mar</option>
<option label="Apr" value="04">Apr</option>
<option label="May" value="05">May</option>
<option label="Jun" value="06">Jun</option>
<option label="Jul" value="07">Jul</option>
<option label="Aug" value="08">Aug</option>
<option label="Sep" value="09">Sep</option>
<option label="Oct" value="10">Oct</option>
<option label="Nov" value="11">Nov</option>
<option label="Dec" value="12">Dec</option>
</select>
<select name="days">
<option value="DD" selected="selected">DD</option>
<option label="1" value="01">1</option>
<option label="2" value="02">2</option>
<option label="3" value="03">3</option>
<option label="4" value="04">4</option>
<option label="5" value="05">5</option>
<option label="6" value="06">6</option>
<option label="7" value="07">7</option>
<option label="8" value="08">8</option>
<option label="9" value="09">9</option>
<option label="10" value="10">10</option>
<option label="11" value="11">11</option>
<option label="12" value="12">12</option>
<option label="13" value="13">13</option>
<option label="14" value="14">14</option>
<option label="15" value="15">15</option>
<option label="16" value="16">16</option>
<option label="17" value="17">17</option>
<option label="18" value="18">18</option>
<option label="19" value="19">19</option>
<option label="20" value="20">20</option>
<option label="21" value="21">21</option>
<option label="22" value="22">22</option>
<option label="23" value="23">23</option>
<option label="24" value="24">24</option>
<option label="25" value="25">25</option>
<option label="26" value="26">26</option>
<option label="27" value="27">27</option>
<option label="28" value="28">28</option>
<option label="29" value="29">29</option>
<option label="30" value="30">30</option>
<option label="31" value="31">31</option>
</select>
<select name="years">
<option value="YYYY" selected="selected">YYYY</option>
<option label="1971" value="1971">1971</option>
<option label="1972" value="1972">1972</option>
<option label="1973" value="1973">1973</option>
<option label="1974" value="1974">1974</option>
<option label="1975" value="1975">1975</option>
<option label="1976" value="1976">1976</option>
<option label="1977" value="1977">1977</option>
<option label="1978" value="1978">1978</option>
<option label="1979" value="1979">1979</option>
<option label="1980" value="1980">1980</option>
<option label="1981" value="1981">1981</option>
<option label="1982" value="1982">1982</option>
<option label="1983" value="1983">1983</option>
<option label="1984" value="1984">1984</option>
<option label="1985" value="1985">1985</option>
<option label="1986" value="1986">1986</option>
<option label="1987" value="1987">1987</option>
<option label="1988" value="1988">1988</option>
<option label="1989" value="1989">1989</option>
<option label="1990" value="1990">1990</option>
<option label="1991" value="1991">1991</option>
<option label="1992" value="1992">1992</option>
<option label="1993" value="1993">1993</option>
<option label="1994" value="1994">1994</option>
<option label="1995" value="1995">1995</option>
<option label="1996" value="1996">1996</option>
<option label="1997" value="1997">1997</option>
<option label="1998" value="1998">1998</option>
<option label="1999" value="1999">1999</option>
<option label="2000" value="2000">2000</option>
<option label="2001" value="2001">2001</option>
<option label="2002" value="2002">2002</option>
<option label="2003" value="2003">2003</option>
<option label="2004" value="2004">2004</option>
<option label="2005" value="2005">2005</option>
</select></td>
</tr>

<tr>
<td align="right" valign="bottom"><font color="white">Gender *</td>
<td>
<div name="div_gender" id="div_gender"></div>
<input type="radio" name="gender" id="gender" value='m'><font color="white"> male</font>
<input type="radio" name="gender" id="gender" value='f'><font color="white"> female</font>
</td>
</tr>

<tr>
<td align="right" valign="bottom"><font color="white">Type the characters below *</font></td>
<td valign="bottom"><div name="div_visual" id="div_visual"></div><input type="text" name="visual" id="visual"></td>
</tr>

<tr>

<td valign="top">(Letters are not case sensitive)&nbsp;&nbsp;</td>

<td valign="top">
<div id="div_captcha">
<p>This will load the the content of external articles into this DIV</p>
</div>
</td>[/html]
[html]<td>
<img alt="Request new image" align="right" src="req_im.gif" onclick="CAPTCHA()">

</td>

</tr>

<tr>
<td></td>
<td align="left">
<textarea onfocus="this.rows=30" border=1 style="text-align:left" rows="5" cols="55" style="color:white;background-color:rgb

(45,45,70); overflow:hidden" readonly onblur="this.rows=5">

TERMS & CONDITIONS
In order to use the Services, you must first agree to the Terms. You may not use the Services if you do not accept the Terms.

1.You acknowledge and agree that if Webmail disables access to your account, you may be prevented from accessing the

Services, your account details or any files or other content which is contained in your account.

2.You agree that any registration information you give to Webmail will always be accurate, correct and up to date.

3.You understand that by using the Services you may be exposed to Content that you may find offensive, indecent or

objectionable and that, in this respect, you use the Services at your own risk.

4.The Terms will continue to apply until terminated by either you or Google as set out below.

5.Unless you have agreed otherwise in writing with Webmail, nothing in the Terms gives you a right to use any of Webmail’s

trade names, trade marks, service marks, logos, domain names, and other distinctive brand features.
</textarea>
</td>
</tr>

<tr>
<td align="right" valign="bottom">
<input type="checkbox" name="terms" id="terms" checked onclick="agreeTerms()">
</td>
<td>
<div id="div_terms" name="div_terms" ></div>
<font color="white">I agree to the terms and conditions.</font>
</td>
</tr>

</table>


<br>
<div align="center">
<input type="submit" name="register" id="register" value="register">
</div>
</form>
</font>
</body>
</html>[/HTML]


//contents of captcha.php


[PHP]<?php

srand(time());

for($i=0;$i<5;$i++)
{
$string=(rand()%6);
echo $string;


}

?>[/PHP]
Oct 23 '07 #7
acoder
16,027 Recognized Expert Moderator MVP
there r no error messages
but in the status bar of Internet Explorer it shows error on page.
Double-click on the error icon. What does the error message say?
i m sending the whole file now.
Please use code tags when posting code:
[CODE=javascript]
Your JavaScript code goes here...
[/code]
Oct 23 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Krishna Kumar | last post by:
Hai all, I am doing a project in .net and in that project I have a problem in capturing text from an image. i.e images like CAPTCHA images . which has inbuilt text with in the image.So,...
0
by: want2learn | last post by:
Hi. I have this CAPTCHA image for .Net in C-Sharp and translate it into VB and as Code_Behind. http://www.mbarrick.com/blog/d6plinks/20061221-01 If i run the site/script i get the site but...
0
by: aaronwmail-usenet | last post by:
Announcing SkimpyGimpy Support for PNG image CAPTCHA generation and PNG canvases. You can now use SkimpyGimpy to generate CAPTCHA text representations as PNG image files in addition to...
4
by: xeiter | last post by:
Hi, I have a captcha script on my website located at /captcha.php. What it does it generates an image with the code, displays the image (gd2) and saves the value of the code in session. How do I...
4
by: mathewgk80 | last post by:
Hi all, I displaed some random numbers in a textbox.. I am having a captcha image and i would like to display that random numbers in captcha image.. The code i used to display the random...
11
by: Twayne | last post by:
Hi, Learning PHP code; playing with various methods of generating captcha codes: In the code below, how would I change the size of the text displayed in the captcha code? Is it even possible...
0
by: readnlearn | last post by:
hai, i have written this below code for displaying captcha image whenever i entered incorrect uname,password in login page. for that i disable the controls of captcha like textbox,labels,button and...
1
by: thiago freitas | last post by:
Guys, first, which is way is, I already saw source code that works with Java and C # with the class of httpclient apache, now how do I get in php captcha bring the image on the screen and then send...
1
by: swatcat | last post by:
Hi I have implemented Captcha in JAVA using Buffered Image and finally using write of ImageIO But the File into which i am writing is not getting updated ImageIO(image,"jpg",new...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.