Basically I want to protect myself from SQL injections. I have tried searching online and watching videos but cannot understand exactly what I have to change because as far as I can tell, everyone does it a little bit differently. Any help is appreciated!
?php
// Create connection
$con = mysqli_connect("IPAddress","User","Password","DBName");
// Check connection
if ($con->connect_error) {
die("Connection failed: " . $con->connect_error);
}
$sql = "INSERT INTO Email_Subs (email)
VALUES ('$_POST[email]')";
if ($con->query($sql) === TRUE) {
echo "You have successfully subscribed!";
} else {
echo "Error: " . $sql . "<br>" . $con->error;
}
$con->close();
?>