PDA

View Full Version : مشکل در sassion در ci



mahdi_smf
یک شنبه 22 دی 1392, 17:08 عصر
سلام من مشکلی که دارم اینه که سیشن منو توی کنترول نمیشناسه.اینم کدهام.خواهشا کمکم کنید.
<?php
class test extends ci_controller{
public function index(){






$this->load->database();



$this->load->helper('captcha');
$vals = array(
'img_path' => './captcha/',
'img_url' => 'http://localhost/captcha/'
);
$cap = create_captcha($vals);
$data = array(

'captcha_time' => $cap['time'],
'word' => $cap['word']
);
$query = $this->db->insert_string('tb', $data);
$this->db->query($query);




echo 'Submit the word you see below:';
echo $cap['image'];
echo '<input type="text" name="captcha" value="" />';

// First, delete old captchas
$expiration = time()-7200; // Two hour limit
$this->db->query("DELETE FROM tb WHERE captcha_time < ".$expiration);
// Then see if a captcha exists:
$sql = "SELECT COUNT(*) AS count FROM tb WHERE word = ? AND captcha_time > ?";
$binds = array(@$_POST['captcha'], $expiration);
$query = $this->db->query($sql, $binds);
$row = $query->row();

echo $row->count;
if ($row->count == 0 )
{
echo "You must submit the word that appears in the image";


}
else
{
@session_start();
@$_SESSION['ok']="ok";
}

}
}

?>

<?php
class form extends ci_controller{
public function index(){
@session_start();

$this->load->helper(array('form', 'url'));

$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'Username', 'required');
$this->form_validation->set_rules('name', 'name', 'required');
$this->form_validation->set_rules('password', 'Password', 'required');
$this->form_validation->set_rules('email', 'email', 'required');




if ($this->form_validation->run()==false and @$_SESSION['ok']=='ok')
{


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

}
else
{
$this->load->view('index');

}
}
}
?>