Welcome Guest, Not a member yet? Register   Sign In
Trouble while Integrating Query in CI
#1

[eluser]Mizanur Islam Laskar[/eluser]
Hi,

This is my first posting on a very peculiar trouble while while integrating jQuery in CodeIgniter. I'm trying to develope an AJAX registration form and I'm getting the following problems:

1) I'm not getting confirmation for any field when I go to the next field pressing TAB
2) Backend .php files for AJAX works are not functoning properly, hence getting wrong data.

But I don't face the above problems when I develope from scratch. Can anybody give me a help plz? I'm sure, if its solved, then it should be an asset for many beginers CI developers. I'm stating my files as below:

Portion of config.php:
Code:
$config['base_url']    = "http://localhost/projects/inbook";

//Define CSS Files
$config['inner_css'] = "assets/styles/inner_page.css";
$config['milk'] = "assets/styles/milk.css";
$config['chili'] = "assets/styles/chili.css";

//Define JavaScript Files
$config['jquery'] = "assets/JavaScripts/jquery.js";
$config['jquery_ajaxQueue'] = "assets/JavaScripts/jquery.ajaxQueue.js";
$config['jquery_delegate'] = "assets/JavaScripts/jquery.delegate.js";
$config['jquery_metadata'] = "assets/JavaScripts/jquery.metadata.js";
$config['jquery_validate'] = "assets/JavaScripts/jquery.validate.js";

//Define PHP Files
$config['captcha'] = "assets/PHPforAjax/captcha.php";
$config['check_captcha'] = "assets/PHPforAjax/check_captcha.php";
$config['check_email'] = "assets/PHPforAjax/check_email.php";


For the above CSS and JavaScript files, please browse http://jquery.bassistance.de/validate/demo/milk/ in Fireowrks and download those files using JS view extension.

captcha.php
Code:
<?
//include("config.inc");  
session_start();  
$width = 100;  
$height = 50;  
$im = imagecreate($width, $height);  
$bg = imagecolorallocate($im, 174, 214, 91);  

// generate random string  
$len = 5;  
$chars = '0123456789';  
$string = '';  
for ($i = 0; $i < $len; $i++) {  
   $pos = rand(0, strlen($chars)-1);  
   $string .= $chars{$pos};  
}  
$_SESSION['captcha_code'] = md5($string);  

// grid  
$grid_color = imagecolorallocate($im, 253, 236, 117);  
$number_to_loop = ceil($width / 20);  
for($i = 0; $i < $number_to_loop; $i++) {  
   $x = ($i + 1) * 20;  
   imageline($im, $x, 0, $x, $height, $grid_color);  
}  
$number_to_loop = ceil($height / 10);  
for($i = 0; $i < $number_to_loop; $i++) {  
   $y = ($i + 1) * 10;  
   imageline($im, 0, $y, $width, $y, $grid_color);  
}  

// random lines  
$line_color = imagecolorallocate($im, 254, 185, 80);  
for($i = 0; $i < 30; $i++) {  
   $rand_x_1 = rand(0, $width - 1);  
   $rand_x_2 = rand(0, $width - 1);  
   $rand_y_1 = rand(0, $height - 1);  
   $rand_y_2 = rand(0, $height - 1);  
   imageline($im, $rand_x_1, $rand_y_1, $rand_x_2, $rand_y_2, $line_color);  
}  

// write the text  
$text_color = imagecolorallocate($im, 110, 110, 206);  
$rand_x = rand(0, $width - 50);  
$rand_y = rand(0, $height - 15);  
imagestring($im, 10, $rand_x, $rand_y, $string, $text_color);  

header ("Content-type: image/png");  
imagepng($im);  
?&gt;

check_captcha.php
Code:
&lt;?

session_start();

if(isset($_GET['captcha']) && isset($HTTP_SESSION_VARS['captcha_code']))
    {
     if(md5($_GET['captcha']) == $HTTP_SESSION_VARS['captcha_code'])
        {
         $valid = 'true';
         }
    else
        {
         $valid = 'false';
         }
    }
else
    {
     if(!isset($_GET['captcha']))
        {
         $valid = 'false';
         }
     if(!isset($HTTP_SESSION_VARS['captcha_code']))
        {
         $valid = 'false';
         }
     }
    
echo $valid;    
        
?&gt;

check_email.php

Code:
&lt;?

    include("config.php");
    
    $email = trim(strtolower($_REQUEST['email'];
    $r_chk = mysql_query("SELECT user_email FROM user_profile WHERE user_email='$email'");
    if(mysql_num_rows($r_chk) > 0)
        {
         $valid = 'false';
         }
    else
        {
         $valid = 'true';
         }
        
    echo $valid;

?&gt;

Please see my View and Controller files in my next posting


Messages In This Thread
Trouble while Integrating Query in CI - by El Forum - 06-30-2008, 12:28 AM
Trouble while Integrating Query in CI - by El Forum - 06-30-2008, 12:48 AM
Trouble while Integrating Query in CI - by El Forum - 06-30-2008, 01:13 AM
Trouble while Integrating Query in CI - by El Forum - 06-30-2008, 02:04 AM
Trouble while Integrating Query in CI - by El Forum - 06-30-2008, 03:16 AM
Trouble while Integrating Query in CI - by El Forum - 06-30-2008, 03:32 AM
Trouble while Integrating Query in CI - by El Forum - 06-30-2008, 11:54 AM
Trouble while Integrating Query in CI - by El Forum - 06-30-2008, 12:45 PM
Trouble while Integrating Query in CI - by El Forum - 06-30-2008, 02:01 PM
Trouble while Integrating Query in CI - by El Forum - 06-30-2008, 02:14 PM
Trouble while Integrating Query in CI - by El Forum - 06-30-2008, 02:23 PM
Trouble while Integrating Query in CI - by El Forum - 06-30-2008, 02:55 PM



Theme © iAndrew 2016 - Forum software by © MyBB