Codeigniter Email

Step 1
php.ini>uncomment opsenssl

Step 2
In email controller,
function email(){
$config[‘protocol’] = ‘smtp’;
$config[‘smtp_host’] = ‘ssl://smtp.googlemail.com’;
$config[‘smtp_port’] = 465;
$config[‘smtp_user’] = ‘miss.sumyatnoepwint@gmail.com’;
$config[‘smtp_pass’] = ‘chochowintintun’;
$this->load->library(’email’, $config);
$this->email->set_newline(“\r\n”);
$this->email->from(‘miss.sumyatnoepwint@gmail.com’, ‘Su Myat’);
$this->email->to(‘sumyat@a.com’);
$this->email->subject(‘This is an email test’);
$this->email->message(‘It is working. Great!’);
if($this->email->send())
{
echo ‘Your email was sent, successfully.’;
}

else
{
show_error($this->email->print_debugger());
}
}

Turn on Remote Desktop

Step one
sshot-2009-10-19-01-25-09

Step two
sshot-2009-10-19-01-24-35

Step three
sshot-2009-10-19-01-23-27

Step four
Search Remote Desktop Connection in window search box

Step five
type 192.168.0.111

Note: The computer which used as remote computer will logoff when the other computer start access to that computer.
Then, enjoy it!

Setup cron job on local server

Go to Startmenu->All Programs->Accessories->System Tools->Task Scheduler->create Task

In the new window we having 4 options

1. General (Give the Task name and for testing you can select “Run when User is logged in“)

2. Trigger (You can Select the running interval as “daily,weekly,monthly”. )

3. Action (This is most important part.Select a Mozilla firefox as the “program/script” and in the Argument provide the URL to fire with Mozilla firefox like http://www.waytocode.com/mycron.php).

To DO:
Create a task give Running time in Trigger setting.Then in Action setting option in the “Program/Script” command textbox type
C:\xampp\php\php.exe
and in the “Add arguments (optional)” type
-f c:/xampp/htdocs/mycron.php

How to sort ID due to where clause used with IN(..)

SELECT *
FROM `question`
WHERE `id`
IN ( 9, 11, 175, 16 )

The results will be displayed where ids are 9, 11, 175, 16, but the results will be asc by id(9,11,16,175). If you don’t want to use automatic sorting or just list according to 9,11,175,16 add ORDER BY FIELD.

SELECT *
FROM `question`
WHERE `id`
IN ( 9, 11, 175, 16 )
ORDER BY FIELD( id, 9, 11, 175, 16)

Using curl for codeigniter REST

http://philsturgeon.co.uk/code/codeigniter-curl

1. copy curl file to library file
2. There would be two controller in ci. One for sending data in JSON format and one for receiving data in JSON format by json_decode.
To insert data into MySQL db from data from android,
In one controller(eg. client_test controller),
function client_register()
{
$username = ‘admin’;
$password = ‘1234’;

$this->load->library(‘curl’);

$this->curl->create(‘http://hsbc.local/api/client/register/format/json’);

// Optional, delete this line if your API is open
$this->curl->http_login($username, $password);

$data = array (
“type_id” => 1,
“agent_id” => 2,
“first_name” => “Joanna”,
“last_name” => “Lee”,
“phone” => “234555”,
“address” => “Mandalay”,
“city” => “Mandalay”,
“mobile” => “095053453”,
“email” => “lee@gmail.com”,
“createddate” => “2013-10-04”,
“modifieddate” => “2013-10-0”
);

$json = json_encode($data);
$this->curl->post(array(
‘postdata’ => $json
));
$result = json_decode($this->curl->execute());
print_r($result);
}
In the other controller(client controller) that might extends REST_Controller(https://github.com/philsturgeon/codeigniter-restserver),
function create_post()
{
try
{
$json = $this->post(‘postdata’);
$data = json_decode($json);
$this->db->insert(‘client’, $data);
$message = json_encode(array(“last_insert_id” => $this->db->insert_id()));
$this->response($message, 200);
}
catch (Exception $e)
{
$this->response(array(‘error’ => $e->getMessage()), 500);
}
}
Then, in the url type client_register, then if it is successfully inserted it will display last insert id.