Answers for "php prevent xss and sql injection"

PHP
4

How can I prevent SQL injection in PHP?

//Connect
$unsafe_variable = $_POST["user-input"];
$safe_variable = mysql_real_escape_string($unsafe_variable);

mysql_query("INSERT INTO table (column) VALUES ('" . $safe_variable . "')");
//Disconnect
Posted by: Guest on May-18-2020
0

prevent xss php

echo htmlspecialchars($string_to_display, ENT_QUOTES, 'UTF-8');
Posted by: Guest on July-07-2021

Code answers related to "php prevent xss and sql injection"

Browse Popular Code Answers by Language