For my school homework I have to create a function that uses trim()
, htmlspecialchars()
and mysql_real_escape_string()
to prevent SQL- and HTML injection.
I've been trying for a while but I can't get it to work. I've tried a foreach
loop and an extract
function. I must be doing something wrong, or missing something.
So far, I've got this: (just to see if the variables are being processed)
foreach ($_Post as $Key => $Value) {
$$Key = $Value;
echo $$Key."<br>";
}
But it won't return anything.
I can use the trim
etc on every variable on its own, but there must be a much easier way.
I've got the $_POST
variables 'voorletters', 'tussenvoegsel', 'naam', 'adres', 'huisnummer' (numbers), 'telefoon' (numbers), 'postcode', 'woonplaats', 'geslacht', 'email' and 'wachtwoord' (password).
Please help me :(! I'm a beginner concerning php, so please try to explain thoroughly.