का उपयोग कर सत्यापन के बाद POST डेटा का उपयोग करना मेरे पास एक साइनअप फॉर्म है जहां मैं उपयोगकर्ता इनपुट को मान्य कर रहा हूं। यहाँ मेरी नियंत्रक है:कोडइग्निटर
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
class Register extends CI_Controller {
public function index()
{
$this->load->model('Users_model');
$this->load->helper('form');
$this->load->library('form_validation');
$data['page_title'] = 'Register';
$this->load->view('header', $data);
// Set form validation rules
$this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[5]|max_length[16]|xss_clean|callback_username_check');
$this->form_validation->set_rules('email', 'Email', 'trim|required|min_length[5]|max_length[64]|valid_email|callback_email_check');
$this->form_validation->set_rules('password', 'Password', 'required');
$this->form_validation->set_error_delimiters('<span class="error">', '</span>');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('register', $data);
}
else
{
// Add the user to the database
$this->Users_model->add_user();
$this->load->view('register_success', $data);
}
$this->load->view('footer', $data);
}
/* Functions to check username and email */
}
/* End of file register.php */
/* Location: ./application/controllers/register.php */
समस्या इस लाइन के साथ है: $this->Users_model->add_user();
। मैं उपयोगकर्ता को अपने डेटाबेस में उपयोगकर्ता जोड़ने के लिए उपयोगकर्ता नाम, ईमेल और पासवर्ड पास करना चाहता हूं, लेकिन मुझे यकीन नहीं है कि मैं उस विधि में POST डेटा कैसे प्राप्त कर सकता हूं। आम तौर पर मैं $_POST['username']
आदि का उपयोग करता हूं लेकिन कोडइग्निटर ने इनपुट मानों पर कुछ फ़ंक्शन चलाए हैं (trim()
, xss_clean
आदि)। मैं इन मानों को कैसे प्राप्त कर सकता हूं और उन्हें अपने add_user()
विधि में कैसे पास कर सकता हूं?
सोचा करने के लिए सरणी भेज यह होगा लेकिन मुझे यकीन नहीं था कि सोचा था कि मैं पूछूंगा। धन्यवाद। :) –
आपका स्वागत है! क्या आप मेरा जवाब स्वीकार करते हैं या स्वीकार करते हैं? – birderic
एसओ मुझे तुरंत जवाब स्वीकार करने की अनुमति नहीं देता है, स्पष्ट रूप से मैं 3 मिनट में कर सकता हूं। :) –