Hai friends…
plz help me ...iam a new web developer with 3 months exp…now iam using CURL in my website for login to a remote site…but
the response going to the login page…but i need it goes to the dashboard….
iam giving my codes in the controller page and curl library page…plz correct it…and post me…....
***************controller page code*********************
<?php
class home extends Controller{
function index()
{
//$this->load->model('home_model');
//$data['result'] = $this->home_model->getData();
$data['page_title'] = "CI Hello World App!";
$this->load->view('home',$data);
}
function curllogin()
{
$username=$_POST["username"];
$password=$_POST["password"];
$this->load->library('curl');
//for loading page
//echo $this->curl->simple_get('http://8.14.146.44/CDR/');
//$this->curl->simple_post('controller/method', array('foo'=>'bar'));
// Start session (also wipes existing/previous sessions)
$this->curl->create('http://8.14.146.44/CDR/');
// Option & Options
$this->curl->option(CURLOPT_BUFFERSIZE, 10);
$this->curl->options(array(CURLOPT_BUFFERSIZE => 10));
// Login to HTTP user authentication
$this->curl->http_login(''.$username.'', ''.$password.'');
// Post - If you do not use post, it will just run a GET request
$post = array('foo'=>'bar');
$this->curl->post($post);
// Cookies - If you do not use post, it will just run a GET request
$vars = array('foo'=>'bar');
$this->curl->set_cookies($vars);
// Proxy - Request the page through a proxy server
// Port is optional, defaults to 80
//$this->curl->proxy('http://8.14.146.44/CDR/', 8080);
//$this->curl->proxy('http://8.14.146.44/CDR/');
// Proxy login
//$this->curl->proxy_login(''.$username.'', ''.$password.'');
// Execute - returns responce
$result = $this->curl->execute();
echo $result;
// Debug data ------------------------------------------------
// Errors
$this->curl->error_code; // int
$this->curl->error_string;
// Information
$this->curl->info; // array
}
}
?>
********************curl library**************
i am giving only execute function......
public function execute()
{
// Set two default options, and merge any extra ones in
if(!isset($this->options[CURLOPT_TIMEOUT])) $this->options[CURLOPT_TIMEOUT] = 30;
if(!isset($this->options[CURLOPT_RETURNTRANSFER])) $this->options[CURLOPT_RETURNTRANSFER] = TRUE;
if(!isset($this->options[CURLOPT_FOLLOWLOCATION])) $this->options[CURLOPT_FOLLOWLOCATION] = TRUE;
if(!isset($this->options[CURLOPT_FAILONERROR])) $this->options[CURLOPT_FAILONERROR] = TRUE;
if(!empty($this->headers))
{
$this->option(CURLOPT_HTTPHEADER, $this->headers);
}
$this->options();
// Execute the request & and hide all output
$res=$this->responce = curl_exec($this->session);
//print_r($res);
// Request failed
if($this->responce === FALSE)
{
$error_code = $this->error_code = curl_errno($this->session);
$error_string = $this->error_string = curl_error($this->session);
echo "login not success";
echo $error_string;
echo "<br>".$error_code;
// $info = $this->info = curl_getinfo($this->session);
//print_r($info);
curl_close($this->session);
$this->session = NULL;
return FALSE;
}
// Request successful
else
{
$info = $this->info = curl_getinfo($this->session);
//print_r($info);
// echo "login success";
// $this->debug($this->session);
curl_close($this->session);
$this->session = NULL;
return $this->responce;
// header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname
//($_SERVER['PHP_SELF']) . "/index.php");
}
}
iam waiting for ur reply…..........if any doubt regarding this ask me…i need it urgent plz help….
