I'm using session data to set the value of an event title, but with titles that contain an apostrophe, like Britain's Digital Future, a \ keeps appearing before the apostrophe. So every time I submit the form the event title gets set to Britain\'s Digital Future with more slashes appearing each time the form is submitted. For example, if I set it 3 times the new title is Britain\\\\'s Digital Future. How can I stop this from happening? It is ruining my search function because the title cannot be found with the slashes in!
HTML:
<tr rowspan="2">
<td>Event</td>
<td>
<div class="form-group ui-widget <?php echo $errors['event_title'] ? 'has-error':''; ?>">
<input class="form-control" id="event_title" name="event_title" placeholder="Enter event name..." aria-describedby="helpBlock" value="<?php echo $values['event_title'] ?>">
<?php echo $errors['event_title'] ? "<span id='helpBlock' class='help-block'>{$errors['event_title']}</span>":''; ?>
</div>
</td>
</tr>
PHP:
if(empty($_POST['event_title'])) {
$_SESSION['errors']['event_title'] = 'You must enter an event title!';
}
if(!$event_id && !empty($_POST['event_title'])) {
$_SESSION['errors']['event_title'] = 'No event with that title was found!';
}
$_SESSION['values']['event_title'] = $_POST['event_title'];
$errors = $_SESSION['errors'];
$values = $_SESSION['values'];