• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help for CSRF/XSS and form validation

#1
1. In CI4, how to escape data during form submission? If i need to escape tags or CSS codes, how to do this? I want to work with HtmlSanitizer.

2. My validation rules are:
PHP Code:
$rules = [
    "inputName1" => "required",
    "inputName2" => "required",
    ........
];
if( ! 
$this->validate($rules) ) 
    return = array('FAILED!'json_encode($this->validator->getErrors())); 

a) How to set name for the each input in error message?
b) As i am submitting the form with AJAX, validation error always executing the success block with validation error message. Ajax is not getting the error headers. How to solve this?

3. How to set custom error header code and message in CI 4?

Thanks in advance and sorry for too many questions.
My "Creative Parents" were created me on 11 December of 1990
Reply

#2
@webdevron,

1. does this help: https://codeigniter4.github.io/userguide...nction#esc
2. (a) try this: https://codeigniter4.github.io/userguide...your-rules
(b) when the form is submitted what does it return?
3. try this: https://codeigniter4.github.io/userguide...validation
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.