0

I have a website in CodeIgniter 3. I have a login and register form. In Register form, I am using CodeIgniter validation rules for validating user inputs. Other are fine, I just want to talk about the email validation rule. Here is how I am doing this

$this->form_validation->set_rules('email', 'Email Address', 'trim|required|max_length[60]|valid_email|xss_clean|unique[user.email]');

And in HTML I have used the Input type attribute email. This attribute forces normal users to enter valid email addresses that's fine. But when I remove this email attribute, I am able to enter this as an email,

"<!sadasdd_?"@gmail.com

How is this a valid email? How do you validate email? and how can I prevent such spam inputs?

halfer
  • 19,824
  • 17
  • 99
  • 186
mrcoder
  • 350
  • 2
  • 13
  • Why you tried to remove the HTML `email` attribute? The defines a field for an e-mail address. With the `email` attribute, the input value is automatically validated to ensure it is a properly formatted e-mail address. – Mahmud Hasan Jion Jul 17 '21 at 14:43
  • @MahmudHasanJion I did that to check the validation because I saw few entries in the database like those, so I tried, validation working or not, and I was able to register an account with an invalid email. – mrcoder Jul 17 '21 at 16:49
  • That is a valid email. When you have double quotes in the first part, you can put almost any garbage in there. – mickmackusa Apr 08 '23 at 10:20

0 Answers0