I'm having a few problems sending a variable via a session.
Index:
PHP Code:
session_start();
$_SESSION['message'] = 'THIS ATTRACTION HAS BEEN EDITED:' . ' ' . $attraction_name;
header('Location: .');
exit();
Display page:
PHP Code:
<?php session_start(); if (isset($_SESSION['message'])) { echo $_SESSION['message']; unset($_SESSION['message']); } ?>
Using the above, if the attraction 'St. Paul's Cathedral' ($attraction_name) was used (having first been sanitized with mysqli_real_escape_string for entry into the database), the echoed output via the session would be:
'THIS ATTRACTION HAS BEEN EDITED: St. Paul\'s Cathedral'.
Obviously it is not being converted by htmlspecialchars (hence the backslash) but I can't figure out where I can use that function. I've tried using it in various places and even tried creating a variable to be used specifically for the session (all to no avail) i.e.:
PHP Code:
$attraction_name_session_output = htmlspecialchars($attraction_name, ENT_QUOTES, 'UTF-8');
It also obviously works if I use the below, but I would have thought that poses a security risk given user-generated content is being run through a session? Or should I not worry given this is not entered into the database?:-
PHP Code:
$_SESSION['message'] = 'THIS ATTRACTION HAS BEEN EDITED:' . ' ' . $_POST['attraction_name'];
Any ideas? Thanks!
Bookmarks