Codeigniter is not decoding email address |
I am sending my email address through a form which is submitted by ajax to controller and the data for the ajax is created by this function:
// Function "serializeToJson" - Serialize form data, merge new object and returns json object function serializeToJson(element, newObj){ // Serialize form and split into Json Object var data = element.serialize().split("&"); var object = {}; for(var key in data){ object[data[key].split("=")[0]] = data[key].split("=")[1]; } // Merge new json obj to existing json object const target = {}; $.extend(target, newObj, object); // return the final json object return target; } and in my ajax data : serializeToJson(SUform, {action:'process_signup'}), **The email which is being sent through the form is getting urlencoded i.e.** > xxxxxxxxxx%40gmail.com the **%40** should be decoded to **@** when i receive the data in my controller. In my controller i have set the following form validation rules for email: $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email|is_unique[users.email]'); **The error:** > The Email field must contain a valid email address **What i want?** Is there any way by which i can urldecode the email in form validation ?
According to CI3 documentation we can easily set a valid php function in the form validation third parameter. in my case i d need to use
$this->form_validation->set_rules('email', 'Email', 'trim|**urldecode**|required|valid_email|is_unique[users.email]');
Are you json_decode(array) in your controller?
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |