codeigniter

Codeigniter - check if user is logged and exists (it's a real user)

ぃ、小莉子 提交于 2020-01-03 13:03:06
问题 I'm trying to set session data for users when they log in to my website. So if the user exists in db, I set a session data like : $this->session->set_userdata('user_exists','1'); Now every time i want to check if user exists and is logged i do: if($this->session->userdata('user_exists')){ //do somenthing for logged user } Now I'm wondering if this means that user is logged and exists in the database since he logged and I set him a session param, is this true? Or I'll get security problems? NB

Codeigniter - check if user is logged and exists (it's a real user)

白昼怎懂夜的黑 提交于 2020-01-03 13:02:39
问题 I'm trying to set session data for users when they log in to my website. So if the user exists in db, I set a session data like : $this->session->set_userdata('user_exists','1'); Now every time i want to check if user exists and is logged i do: if($this->session->userdata('user_exists')){ //do somenthing for logged user } Now I'm wondering if this means that user is logged and exists in the database since he logged and I set him a session param, is this true? Or I'll get security problems? NB

SQL join in CodeIgniter with Active Record

佐手、 提交于 2020-01-03 11:04:17
问题 I'm trying to wrap my head around this, but I seem to go in circles. I'm trying to list a users topics one by one, with the quotes belonging to that specific topic underneath. If that makes sense. I have 3 tables, like so: [USERS] user_id username [TOPICS] topic_id user_id topic_name [QUOTES] quote_id topic_id quote_name I want to be able to do something like this in my view: Username: Thomas Topic 1: Whatever Quotes: One quote, another quote, and a third quote, all belonging to Topic 1.

SQL join in CodeIgniter with Active Record

这一生的挚爱 提交于 2020-01-03 11:04:08
问题 I'm trying to wrap my head around this, but I seem to go in circles. I'm trying to list a users topics one by one, with the quotes belonging to that specific topic underneath. If that makes sense. I have 3 tables, like so: [USERS] user_id username [TOPICS] topic_id user_id topic_name [QUOTES] quote_id topic_id quote_name I want to be able to do something like this in my view: Username: Thomas Topic 1: Whatever Quotes: One quote, another quote, and a third quote, all belonging to Topic 1.

Check if cookie exists in CodeIgniter

别来无恙 提交于 2020-01-03 10:47:33
问题 I'm using a search system, in PHP, that adds the text searched to an array and put it inside a cookie using json_encode(). The problem is: I need to check if the cookie already exists and, if not, create it. I'm using the following code to simply verify if it exists but without success: { $search = $this->input->post('search_text'); $types = $this->input->post('search_type'); $checkboxes = ""; if(!empty($types)) { foreach($types as $v) $checkboxes = $v.","; } //cookie $this->load->helper(

Mysql query to fetch limited rows of each type

佐手、 提交于 2020-01-03 10:22:55
问题 I have a Table in MYSql called companies and each companies has a type say type 1, type 2 type 3, example : id company_name company_type =============================== 1 test1 3 2 xyz 2 3 ashdasdjk 2 4 test 4 1 5 test 3 6 ahsdkjsg 1 7 TCS 2 and so on ... now i want to write a query to fetch results such that i get 20 companies of type 1, 20 companies of type 2 and 20 companies of type 3... i mean i want to fetch maximum of 20 companies of each type I am using Codeigniter.. 回答1: select * from

Error : Object of class CI_DB_mysql_result could not be converted to string

扶醉桌前 提交于 2020-01-03 08:42:08
问题 I'm new to CodeIgniter, I've tried to read the documentation of CI but I still can't solve my problem, maybe someone here can help fix my problem. Here is my code: In my controller class Registration extends CI_Controller{ function __construct(){ parent::__construct(); $this->load->model('registration_model','rmod'); } function ambil() { $gender = $this->input->post('kelamin'); $tinggi = $this->input->post('height'); $berat = $this->input->post('weight'); $weight = $this->rmod->ambilBeratPria

How to restrict the upload image ratio to 16:9 in codeigniter?

倾然丶 夕夏残阳落幕 提交于 2020-01-03 07:11:48
问题 Here is the code I used for uploading an image. $this->load->library('upload'); $ext = pathinfo($file_name, PATHINFO_EXTENSION); $img_name = now() . "." . $ext; $imgConfig['upload_path'] = $this->image_path; $imgConfig['file_name'] = $img_name; $imgConfig['max_size'] = '2048'; $imgConfig['allowed_types'] = 'jpg|png|bmp'; $imgConfig['overwrite'] = FALSE; $this->upload->initialize($imgConfig); if ($this->upload->do_upload("image_url")) { $this->Playlist_model->update_playlist($insert_id, array(

accessing array and objects

社会主义新天地 提交于 2020-01-03 06:39:08
问题 I have a problem with printing my data. In my program, i get the data which was in object and put in an array. say array1[$id] = dataobject. the whole array1 then will be put to array2['list'] like array2['list'] = array1; the problem is how do i get the data such as the id, name and description.. here's the print_r of the whole array: this is actually the result of the array, i am not sure how to access this. i want to foreach and get the name and print them: Array ( [list] => Array ( [0] =>

How to solve the send mail slow in codeIgniter?

谁说胖子不能爱 提交于 2020-01-03 05:54:06
问题 I am using the default codeIgniter mail class, which is very slow for me to send the email, it takes me up to 3 seconds to from start to finish. Can I do something to make the user think it is faster. I know that sending email takes time, but can I show the result to the user first, and send to later or something other workaround? Thanks. 回答1: It won't be the class that is slow, it will be the SMTP mail server you are trying to connect to that sends the email that is making the page lag.