It is currently Wed Sep 03, 2014 6:57 am

All times are UTC


You can access below Applications



Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: what is codeigniter ?
PostPosted: Tue Aug 10, 2010 5:56 am 
Offline
User avatar

Joined: Tue Mar 02, 2010 10:49 am
Posts: 171
Location: India/Tamilnadu/Tirunelveli
Thanks mate, now i coded on all pages for adding unique title and description.

_________________
Anbarasan k


Top
 Profile  
 
 Post subject: Login in using CodeIgniter Framework
PostPosted: Fri Sep 24, 2010 12:50 pm 
Offline
User avatar

Joined: Mon Aug 02, 2010 5:15 am
Posts: 61
Location: Tirupattur/Chennai
All ready we discuss and studied How to Install and Work.
Now we will see Login process

First Controller Class created and saved corresponding controller folder
file name login.php
Code:

<?php
    class Login extends Controller  
    
{
        function index()
        {
        $this->load->helper('url');                      // loads url helper file 
        $this->load->helper('form');                    // loads form helper file
        $this->load->library('session');                // loads session library file 
        $this->load->library('form_validation');       //load the library file                
        $this->form_validation->set_rules('username', 'Username', 'required');
 // set validation rules for the form data
        $this->form_validation->set_rules('password', 'Password', 'required'); 

// 1st parameter is user giving field name in html input tage, 2nd is Message to add 
//error_message & 3rd is condition specified 


            if ($this->form_validation->run() == FALSE)  // check's form  fields are filled
            {
                $this->load->view('login_view'); 
            
}
            else
            
{
                 $username = $this->input->post('username'); // getting form values
                 $password = $this->input->post('password');             
                 $this
->load->model('login_model', '', TRUE);   // load model file
                 $this->load->database();                          // load database
                 $data =$this->login_model->submit_posted_data();                
                     if 
($data->num_rows() != 0)
                     {
                       $userdata = array(
                       'username'  => $username,
                       'password' => $password
                        
);
    
                     $this
->session->set_userdata($userdata);  // setting user value in session
                      redirect('userenter');      
                     
} 
                     else
                     
{
                        $this->load->helper('url');
                        redirect('login');
                     }
                    
            
}
        }
        function logout()
        {
            $this->session->sess_destroy();    // destroy user data complete
            $this->load->helper('url');
            redirect('login');
        }
    }
?>

View file is created and saved views folder
file name login_view.php
Code:

<?php echo form_open('login'); ?> // form tag in CodeIgniter
<div align="right" style="margin:70px 150px">
     <table>
      <td>User Name</td>
      <td><input type="text" name="username" value="<?php echo set_value('username'); ?>" ></td>
<td><?php echo form_error('username', '<div class="error">', '</div>'); ?></td>
    </tr>
    <tr>
      <td>Password</td>
      <td><input type="password" name="password" value="<?php echo set_value('password'); ?>" ></td>
<td><?php echo form_error('password', '<div class="error">', '</div>'); ?></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td align="right"><input type="submit" name="Submit" value="Login"></td>
<td></td>
    </tr>
  </table>


Model file is created and saved in models folder
file name is login_model.php
Code:

<?php
    class Login_model extends Model
    
{
        function login_model()
        {
            parent::Model();
            
        
}
        
        function submit_posted_data
() 
        
{
               $data['result']=$this->db->get_where('login', array('user_name' => 
$_POST
['username'], 'pass_word' => $_POST['password']));       
//get_where () is built in function and check both user name and password       
             return $data['result'];            

        
}    
    
}
?>

_________________
Thanks & Regards,
Image
QualityPoint Technologies,
Chennai.


Top
 Profile  
 
 Post subject: Sign Up Process with Captcha technique in CodeIgniter Framew
PostPosted: Fri Sep 24, 2010 1:46 pm 
Offline
User avatar

Joined: Mon Aug 02, 2010 5:15 am
Posts: 61
Location: Tirupattur/Chennai
Here also follow same steps. Creating three files and save corresponding folders.

First create controller file. file name signup.php

Code:

<?php
    class Signup extends Controller
    
{
        function index()
        {
            $this->load->helper('url');
            $this->load->helper('form');
            $this->load->model('signup_model', '', TRUE);   
            $this
->load->library('form_validation'); //load the library file   
            // 1st user give name, 2nd error message name, 
3rd The validation rules for this form field.             
            $this
->form_validation->set_rules('username', 'Username', 'required|
min_length[5]|max_length[12]'
); 
// set rules for the form data
            $this->form_validation->set_rules('password', 'Password', 'required|
matches[passconf]'
);
            $this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
            $this->form_validation->set_rules('email', 'Email', 'required|
valid_email|matches[conemail]'
);
            $this->form_validation->set_rules('conemail', 'Email', 'required|valid_email');
            $this->form_validation->set_rules('dob', 'DateOfBirth', 'required');        
            $this
->load->model('captcha_model', '', TRUE);
            $captcha = $this->captcha_model->generateCaptcha();
            $_SESSION['captchaWord'] = $captcha['word'];            
            $data
['captcha'] = $captcha;                
            if 
($this->form_validation->run() == FALSE) 
            
{
                $this->load->view('signup_view', $data);
            }        
            else
            
{
                if(strcasecmp($_SESSION['captchaWord'], $_POST['confirmCaptcha']) == 0)
                {
                    $this->load->model('signup_model','', TRUE);
                    if($this->signup_model->get_all_data())
                    {
                        $this->load->helper('url');
                        redirect('login');                    
                    
}
                    else
                    
{
                        echo "Not Insert data to database ";        
                    
}
                }
                else      // Captcha not match this else part will work 
                {
                    $this->load->helper('url');  
                    redirect
('signup');                    
                
}
                        }    
        
}

    }
?>


View file. file name signup_view.php

Code:

<?php echo form_open('signup'); ?>
<div style="margin-top:100px;">
  <table align="center">
      <td>User Name </td>
      <td><input type="text" name="username" id="username"></td>
<td><?php echo form_error('username', '<div class="error">', '</div>'); ?></td>
    </tr>
    <tr>
      <td>Password</td>
      <td><input type="password" name="password" id="password"></td>
<td><?php echo form_error('password', '<div class="error">', '</div>'); ?></td>
    </tr>
    <tr>
      <td>Conform Password</td>
      <td><input type="password" name="passconf" id="passconf"></td>
<td><?php echo form_error('passconf', '<div class="error">', '</div>'); ?></td>
    </tr>
    <tr>
      <td>E-mail ID </td>
      <td><input type="text" name="email" id="email"></td>
<td><?php echo form_error('email', '<div class="error">', '</div>'); ?></td>
    </tr>
    <tr>
      <td>Conform E-mail ID </td>
      <td><input type="text" name="conemail" id="conemail"></td>
<td><?php echo form_error('conemail', '<div class="error">', '</div>'); ?></td>
    </tr>
    <tr>
      <td>Date Of Birth </td>
      <td> <input id="dob" name="dob" value=""  size="12" type="text" 
onFocus="showCalendarControl(this);"></td>
<td><?php echo form_error('dob', '<div class="error">', '</div>'); ?></td>
    </tr>
    <tr>
        <td>Security Code:</td>
        <td>
            <span id="captchaImage"><?php echo $captcha['image']; ?></span> 
        </td><td><input type="button" value="Refresh" onClick="window.location.reload()"></td>
    </tr>    
    <tr>
        <td><label for="confirmCaptcha">Confirm Sercurity Code:</label></td>
        <td>
            <input type="text" name="confirmCaptcha" id="confirmCaptcha" value="" />
        </td><td>&nbsp;</td>
    </tr>    
    <tr>
      <td>&nbsp;</td>
      <td align="right"><input type="submit" value="Register"></td>
    </tr>
  </table>
  </div>
</form>


Model file. file name signup_model.php

Code:

<?php
    class signup_model extends Model
    
{
        function signup_model()
        {
            parent::Model();
            
        
}
        function get_all_data()
        {
            $udata=$this->db->insert('login', array('user_name' => $_POST['username'], 
'pass_word' => $_POST['password'], 'email' => $_POST['email'], 'date' => $_POST['dob']));          
            return $udata
;
        }
    }
?>

_________________
Thanks & Regards,
Image
QualityPoint Technologies,
Chennai.


Top
 Profile  
 
 Post subject: Email Send Using CodeIgniter Framework
PostPosted: Sat Sep 25, 2010 1:52 pm 
Offline
User avatar

Joined: Mon Aug 02, 2010 5:15 am
Posts: 61
Location: Tirupattur/Chennai
CodeIngiter Framework has a separate Library for sending email i.e Email.php. We can only inherit the Features.

First Create Controller class and saved in corresponding controller folder

Code:

<?php
class Email extends Controller 
{

function Email(){

// load controller parent

parent::Controller();

// load 'url' helper

$this->load->helper('url');

// load 'form' helper

$this->load->helper('form');

// load 'validation' class

$this->load->library('validation');

// load 'email' class

$this->load->library('email');

}

function index(){

// set validation rules

$rules['subject']="option";

$rules['message']="options";

$rules['email']="required|valid_email";

$this->validation->set_rules($rules);

// set values to repopulate fields

$fields['subject']='Subject';

$fields['message']= 'Message';

$fields['email']='Email Address';

$this->validation->set_fields($fields);

// check if user form has been submitted properly

if ($this->validation->run()==FALSE){

// redisplay user form and repopulate fields

$this->load->view('form_view');

}

// display confirmation web page and send email

else{

// set email class settings

$this->email->from('sakthiprakash.d@gmail.com', 'Sakthi' . ' '.'Prakash');

$this->email->to($_POST['email']);

$this->email->cc($_POST['cc']);

$this->email->bcc($_POST['bcc']);

$this->email->subject($_POST['subject']);

$this->email->message($_POST['message']);

$data['title']='Sending email...';

$data['header']='Sending email now...';

$data['message']=$this->email->send()?'Message was sent successfully!':'Error sending email!';

$this->load->view('email_view.php',$data);

}

}

}
?>


save as email.php

Next we create two view files and no need of model file because we can't use any database

Code:

<?php echo $this->validation->error_string;?>
<?php echo form_open
('email');?>
<p>Email <input type="text" name="email" value="<?php echo $this->validation->email;?>" size="50" /></p>
<p>Cc <input type="text" name="cc" value="<?php //echo $this->validation->cc;?>" size="50" /></p>
<p>Bcc <input type="text" name="bcc" value="<?php //echo $this->validation->bcc;?>" size="50" /></p>
<p>Subject <input type="text" name="subject" value="<?php echo $this->validation->subject;?>" size="50" /></p>
<p>Message <textarea cols="30" rows="15" name="message"><?php echo $this->validation->message;?></textarea>s</p>
<p><input type="submit" value="Send Data" /></p>
</form>


save as form_view.php
Code:

<h1><?php echo $header;?></h1>
<p><?php echo $message;?></p>
<p><?php echo anchor('email','Go and submit the form again');?></p>
</form>


save as email_view.php

_________________
Thanks & Regards,
Image
QualityPoint Technologies,
Chennai.


Top
 Profile  
 
 Post subject: CodeIgniter HTML Table Class
PostPosted: Sat Sep 25, 2010 2:13 pm 
Offline
User avatar

Joined: Mon Aug 02, 2010 5:15 am
Posts: 61
Location: Tirupattur/Chennai
The Table Class provides functions that enable you to auto-generate HTML tables from arrays or database result sets.

Let's see one example

Here is an example showing how you can create a table from a multi-dimensional array.

Code:

<?php
    class Htmltable extends Controller
    
{
        function index()
        {
            $this->load->library('table'); // load the table library 
            $data = array(
                         array('Name', 'Color', 'Size'), // first array is table header
                         array('Fred', 'Blue', 'Small'),
                         array('Mary', 'Red', 'Large'),
                         array('John', 'Green', 'Medium')
                         );
            
            echo $this
->table->generate($data); // function to generate table              
        }
    }
?>


Here is an example of a table created from a database query result.

Code:

<?php
    class Htmltable extends Controller
    
{
        function index()
        {
        
            $this
->load->library('table');

            $this->load->database(); // this is load the database 

            $query = $this->db->query("SELECT * FROM login");
            
            echo $this
->table->generate($query); 
        
}
    }
?>


$this->table->clear()

The clear() function is clear the table heading and row data. If you need to show multiple tables with different data you should to call this function after each table has been generated to empty the previous table information

Code:

<?php
    class Htmltable extends Controller
    
{
        function index()
        {
            $this->load->library('table');    
            
            $this
->table->set_heading('Name', 'Color', 'Size');
            $this->table->add_row('Fred', 'Blue', 'Small');
            $this->table->add_row('Mary', 'Red', 'Large');
            $this->table->add_row('John', 'Green', 'Medium');

            echo $this->table->generate();
            
            $this
->table->clear();
            
            $this
->table->set_heading('Name', 'Day', 'Delivery');
            $this->table->add_row('Fred', 'Wednesday', 'Express');
            $this->table->add_row('Mary', 'Monday', 'Air');
            $this->table->add_row('John', 'Saturday', 'Overnight');
            
            echo $this
->table->generate(); 
        
}
    }
?>

_________________
Thanks & Regards,
Image
QualityPoint Technologies,
Chennai.


Top
 Profile  
 
 Post subject: Get Current URL
PostPosted: Tue Sep 28, 2010 6:48 am 
Offline
User avatar

Joined: Tue Mar 02, 2010 10:49 am
Posts: 171
Location: India/Tamilnadu/Tirunelveli
In codeigniter to get current url, you could just use:

Code:
$_SERVER['REQUEST_URI']

_________________
Anbarasan k


Top
 Profile  
 
 Post subject: CodeIgniter Framework Zip Encoding Class
PostPosted: Mon Oct 04, 2010 1:41 pm 
Offline
User avatar

Joined: Mon Aug 02, 2010 5:15 am
Posts: 61
Location: Tirupattur/Chennai
This Zip Encoding Class is used to zip the data in various file format, many files and also option for saved in our hard disc automatically.

This file is saved in controllers folder and name codezip.php
Code:
<?php 
    
class Codezip extends Controller
    
{
        function 
index()
        {
            
$name 'mydata1.txt';   // first file name, file saved in notepad format 
            
$data 'A Data String!';  // first file data 
            
$this->load->library('zip');            
            
$this->zip->add_data($name$data);  // function to add zip 
            
            
$name 'mydata2.txt';              // second file name 
            
$data 'Another Data String!';      // second file data 
            
$this->zip->add_data($name$data);
            
            
$name 'personal/my_bio.txt';        // folder inside the file will create 
            
$data 'I was born in an elevator...';            
            
$this->zip->add_data($name$data); 
                        
            
// Write the zip file to a folder on your server. Name it "my_backup.zip"
            
$this->zip->archive('C:/Program Files/Apache Group/Apache2/htdocs/sakthi/sample/my_backup.zip');
            
            
// Download the file to your desktop. Name it "my_backup.zip"
            
$this->zip->download('my_backup.zip'); 
        }
    }
?>

_________________
Thanks & Regards,
Image
QualityPoint Technologies,
Chennai.


Top
 Profile  
 
 Post subject: URL Helper In CodeIgniter Framework
PostPosted: Wed Oct 06, 2010 1:35 pm 
Offline
User avatar

Joined: Mon Aug 02, 2010 5:15 am
Posts: 61
Location: Tirupattur/Chennai
Hi Team,
Here is a sample program to show the built in methods in URL Helper

Code:

<?php
    class Sampleurl extends Controller
    
{
        function index()
        {    
            $this
->load->helper('url');
            echo site_url();  // Returns your site URL, as specified in your config file.
            echo "<br>";
            echo site_url("login"); 
// Returns your site URL, as specified in your config file with additional parameters.
            echo "<br>";
            echo base_url(); // Returns your site base URL, as specified in your config file.
            echo "<br>";
            echo uri_string(); 
// Returns the URI segments of any page that contains this function.
            echo "<br>";
            echo index_page(); 
// Returns your site "index" page, as specified in your config file.
            echo "<br>";
            echo current_url(); 
// Returns the full URL (including segments) of the page being currently viewed.
            echo "<br>";
            echo anchor('login', 'Login Page', array('title' => 'Register user can only login!'));
// Creates a standard HTML anchor link based on your local site URL
            echo "<br>";
            $atts = array(
              'width'      => '800',
              'height'     => '600',
              'scrollbars' => 'yes',
              'status'     => 'yes',
              'resizable'  => 'yes',
              'screenx'    => '0',
              'screeny'    => '0'
            );
            echo anchor_popup('news/local/123', 'Click Me!', $atts);  
// when click the link new pop up will open
            echo "<br>";
            echo mailto('sakthiprakash.d@gmail.com', 'Click Here to Mail Me');  
// it is used to send mail 
            echo "<br>";
            $url = "example.com";
            echo prep_url($url); 
// This function will add http:// in the event it is missing from a URL.
            echo "<br>";
            //echo "redirect()"; 
//redirect('login'); //automatically redirect specified page, nw i commented the redirect one 
            echo "<br>";
            $title = "What's wrong with CSS?";
            echo url_title($title, 'underscore'); 
// insert underscore in all word's
            echo "<br>";
            $string="sakthiprakash.d@gmail.com hai hello http://www.qualitypointtech.com";            
            echo auto_link
($string);        
// automatically detect and auto link the give string  
            echo "<br>";
            echo $this->uri->total_segments(); 
 
// Returns the total number of segments.
            echo "<br>";
            echo $this->uri->slash_segment(1, 'both');
 // default is tailing i.e before and leading 
        }
    }
?>

_________________
Thanks & Regards,
Image
QualityPoint Technologies,
Chennai.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: