Using the Admin page, I want to toggle on/off or enable/disable a php file and I'm using sessions but the session stops as I close the browser. I want to keep the session active even if I close the browser. Am I using the right code? I think it's not session...?
<form method="post" action="">
<td colspan="2" bgcolor="#FFFFFF" valign="left">
<strong>APPLICATION FORM:
<select name="switch" id="switch" align="center" valign="center">
<option></option>
<option>ON</option>
<option>OFF</option>
</strong>
</SELECT>
<input type="submit" name="submit" value="SUBMIT">
<?php
if(isset($_POST['submit'])){
include('config.php');
$switch=($_POST['switch']);
if ($_POST['switch'] == "ON"){
$_SESSION['switch'] = $switch;
echo "<script language='javascript' type='text/javascript'>";
echo "alert('Application form ACTIVATED!');";
echo "</script>";
echo 'ON';
}
if ($_POST['switch'] == "OFF"){
echo "<script language='javascript' type='text/javascript'>";
echo "alert('Application form DEACTIVATED!');";
echo "</script>";
echo 'OFF';
session_destroy();
header('location.href=index.php');
}
}
?>
</td>
</form>
<?php
session_start();
?>
<?php
$con = mysql_connect('localhost','root','');
if (!$con) {
die('Could not connect:'.mysql_error());
}
mysql_select_db ('psp',$con);
if (!isset($_SESSION['switch'])){
header('location:index.php');
}
?>