jeudi 30 juin 2016

How to properly clean html post to save in mysql

I'm trying to create a blog system, I'm at a point where i want to save the blog post data into mysql but little confuse how to clean or sanitize the data here is what I've tried function test_input($data) { $data = trim($data); $data = stripslashes($data); return $data; } Now when i posted blog data through ajax it looked like <h1 class="text-center"> Write the titles of article here </h1> then i clean the post data & echo it echo $title = mysqli_real_escape_string($connecDB, test_input($_POST['page__title'])); Then here is what I got in response rn Write the titles of article herern I want to know why I'm getting these rn in the response how can i get rid of them which is the best way of cleaning html post Note: i want to save the data as html in mysql I already have a regex that will find style & script tags & remove it, i also tried removing strip slashes & tried adding strip_tags also but still I'm getting rn

Aucun commentaire:

Enregistrer un commentaire