Whenever I submit a form to the database it runs this bit:
<?php
include('connect.php');
$title = mysqli_real_escape_string($link, $_POST['title']);
$subtitle = mysqli_real_escape_string($link, $_POST['subtitle']);
$etad = mysqli_real_escape_string($link, $_POST['etad']);
$author = mysqli_real_escape_string($link, $_POST['author']);
$Author_URL = mysqli_real_escape_string($link, $_POST['Author_URL']);
$URL = mysqli_real_escape_string($link, $_POST['URL']);
$sql = "INSERT INTO posts (title, subtitle, etad, author, Author_URL, URL) VALUES ('" . $title . "', '" . $subtitle . "', '" . $etad . "', '" . $author . "', '" . $Author_URL . "', '" . $URL . "')";
if (!mysqli_query($link,$sql)) { die('Error: ' . mysqli_error($link)); }
header("Location: https://www.atheistunlimited.com/beta/index.php?post=success");
?>
But if I store try to store a word with an apostrophe it gets distorted. (EX: Don't
turns into Don’t
)
How would I be able to securely store and retrieve a strings with an apostrophe?