Answer the question
In order to leave comments, you need to log in
How does PHP POST & GET filtering look and work?
Hello. I use this function to filter GET and POST
function formatstr($str)
{
$str = trim($str);
$str = stripslashes($str);
$str = htmlspecialchars($str);
return $str;
};
$login_name=formatstr($_GET['login_name']);
'"<script>
Answer the question
In order to leave comments, you need to log in
How does PHP POST & GET filtering look and work?
$stmt = $conn->prepare("INSERT INTO tablitsa (login_name,email) VALUES (?,?)");
$stmt->bind_param("ss", $login, $email);
$stmt->execute();
trim - This function returns the string str with spaces removed from the beginning and end of the string.
stripslashes - Removes character escaping.
htmlspecialchars — Convert special characters to HTML entities
<?php
function formatstr($str)
{
$str = trim($str);
$str = stripslashes($str);
$str = htmlspecialchars($str);
return $str;
};
$login_name = formatstr('test');
print_r($login_name);
$login_name2 = formatstr('<p>test</p>');
print_r($login_name2);
$login_name3 = formatstr('<p class="test">test</p>');
print_r($login_name3);
?>
test
<p>test</p>
<p class="test">test</p>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question