I'm attempting to create a page that can switch between 2 sets of content, using Sessions and a form button.
Eventually it'll be used in a CMS to switch between an initial preview of how the page content looks and an editable version, but for now I'm just trying to get a basic functioning page I can build on.
Above the doctype I have
<?php
if (array_key_exists('edit', $_POST)) {
session_start();
$_SESSION['authenticated'] = 'Edit';
}
if (isset($_SESSION['authenticated'])) {
$view = 'Editable';
exit;
}
else {
$view = 'Preview';
}
?>
then in the body of the page is a form button 'Edit' and some simple PHP to test if the page works
<?php
if ($view == 'Editable') {
echo "Edit Mode";
} else {
echo "Preview Mode";
}
?>
When the page loads in it shows the Edit button and "Preview Mode", but when you click on Edit it returns a blank page
I'm obviously missing something important, but what?
Or am I going about this completely wrong?
Any help much appreciated
thanks
Steve
Eventually it'll be used in a CMS to switch between an initial preview of how the page content looks and an editable version, but for now I'm just trying to get a basic functioning page I can build on.
Above the doctype I have
<?php
if (array_key_exists('edit', $_POST)) {
session_start();
$_SESSION['authenticated'] = 'Edit';
}
if (isset($_SESSION['authenticated'])) {
$view = 'Editable';
exit;
}
else {
$view = 'Preview';
}
?>
then in the body of the page is a form button 'Edit' and some simple PHP to test if the page works
<?php
if ($view == 'Editable') {
echo "Edit Mode";
} else {
echo "Preview Mode";
}
?>
When the page loads in it shows the Edit button and "Preview Mode", but when you click on Edit it returns a blank page
I'm obviously missing something important, but what?
Or am I going about this completely wrong?
Any help much appreciated
thanks
Steve