1
$sql = "INSERT INTO golf (datum, odkud, odjezd ) VALUES ('$datum', '$odkud', '$odjezd')";
if(!mysqli_query($connection,$sql)) {
echo '<p class="error">Záznam nebyl vložen</p>';
} else {
header ("location :/golf");
}

Hello, I am working on my thesis to school. I have this code and my supervisor keeps telling me to "treat special characters". How do I do that? He only saw the code I showed you.

  • 2
    I think it's about validation. you run the query directly with variables without any validations. so, for security purposes you have to validate the data before run the query or else it will subject to security threas like sql injection. So, search how to validate the request – dilusha_dasanayaka Apr 14 '18 at 12:17
  • How do I validate? I mean, I have date, time and name (of a city) if(empty($datum)) { $errorMessage .= "
  • You forgot to enter a date!
  • "; } if(empty($odkud)) { $errorMessage .= "
  • You forgot to enter a name of a city!
  • "; } if(empty($odjezd)) { $errorMessage .= "
  • You forgot to input odjezd!
  • "; } – Martin Švejda Apr 14 '18 at 12:27