I have the following form on my index.php page that sumbits to a page called live. php
index.php
<form action="live.php" method="POST" enctype="multipart/form-data">
<td>
<label for="event">Create Event: </label>
<input type="text" id="event" name="event" placeholder="Event Name">
<input type="submit" name="saveEvent" value="Add Event">
</td>
</form>
In my live.php page I am using the sumbitted data to create a database.
live.php
if(isset($_POST['event']))
{
$event = $_POST['event'];
$sqlEvent = "CREATE DATABASE `$event`";
mysqli_query($con, $sqlEvent) or die(mysqli_error($con));
}
I then use $event to echo as the title of the page.
<?php
echo '<h1 align="center">', $event ,'</h1><br />';
?>
What happens is when I refresh the page the title disappears. What I am looking for is a way to store $_POST['event'] into a variable/session that I can use until I close the web browser or reset the variable to be empty via a button. Any help with this would be greatly appreciated.
EDIT This is what I tried to get $_SESSION to work, but had no luck
if(isset($_POST['event']))
{
$_SESSION['event'] = $_POST['event'];
echo $_SESSION['event'];
$event = isset($_SESSION['event']) ? $_SESSION['event'] : "no event";
echo $event;
$sqlEvent = "CREATE DATABASE `$event`";
mysqli_query($con, $sqlEvent) or die(mysqli_error($con));
}
It will echo just fine for both, but once I refresh the page I lose the data stored in $event