简体   繁体   English

Codeigniter未解码电子邮件地址

[英]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: 我正在通过ajax提交给控制器的表单发送我的电子邮件地址,而ajax的数据是通过此函数创建的:

// 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 ie 通过表格发送的电子邮件已经被urlencoded,即

xxxxxxxxxx%40gmail.com XXXXXXXXXX%40gmail.com

the %40 should be decoded to @ when i receive the data in my controller. 当我在控制器中收到数据时, %40应该解码为@ 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 ? 有什么方法可以对表单验证中的电子邮件进行url解码?

You can use: 您可以使用:

trim|urldecode|valid_email

It should work as the docs say you can use any php function as a "rule" and it will apply. 它应该像文档所说的那样工作,您可以将任何php函数用作“规则”,它将适用。

You'll still have to urldecode it again for when you put it in the database. 当您将其放入数据库时​​,仍然需要再次对其进行urldecode

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 解码pdf字符串并通过codeigniter电子邮件功能发送它 - decoding pdf string and sending it by codeigniter email functionality Codeigniter如何检查电子邮件地址是否存在 - How to check email address exists or not in codeigniter Codeigniter 无法将 email 发送到存储在数据库中的地址 - Codeigniter cannot sent email to address stored in database 如何在codeigniter中向两个不同的电子邮件地址发送电子邮件 - How to send email to two different email address in codeigniter Codeigniter转Laravel解码 - Codeigniter to Laravel decoding 我如何在 jquery 的帮助下在 codeigniter 中匹配两个电子邮件地址 - How I match two email address in codeigniter with help of jquery 如何在codeigniter中检查电子邮件是否为假地址? (我使用过PHPMailer) - How to check the email is fake address in codeigniter ? (I used PHPMailer) 在codeigniter中获得具有相同电子邮件地址域的用户的最佳方法是什么? - What is the best way to get user with same email address domain in codeigniter? Facebook Graph API的CodeIgniter Auth2库:未获取电子邮件地址 - CodeIgniter Auth2 Library for Facebook Graph API : Not getting email address CodeIgniter safe_mailto 函数不会混淆电子邮件地址 - CodeIgniter safe_mailto function does not obfuscate email address
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM