capcha check in php
===

im going to have a capcha in my form and submit if capcha entered correctly,im using jquery ajax to send entered code for match check . but in true and false capcha entered i get the same result in jquery . 

how can i solve this problem and get the correct result in capcha check?


here is my code, both php and jquery,  

php code(generateimage.php):

    header('Content-type:image/jpeg');
    $text = rand(100000, 999999);
    .
    .
    .
    if(isset($_POST['check_capcha']))
    {
	   $check =$_POST['check_capcha'];
	   if($check == $text)
	   {
		   echo true ;
	   }
	
    }

and jquery:

    var check_capcha = $("#human_check_sub").val();
		 check_capcha = parseInt(check_capcha);
		 $.post("../php/generateimage.php",{check_capcha:check_capcha},function(data){
			 if(data)
			 {
				 //$.post("../php/core.php");
				 alert("ok sub");
			 }
			 else
			 {
				 $("#img_cap_sub").attr("src","../php/generateimage.php");
				 $("#caution_sub").html('<span>Capcha entered incorrect.try again</span>');
				 
			 }
		 });

