<?php session_start();?>

<?php
	if($_SESSION ["role"]=="Administrator")
	{
		$role = $_SESSION["role"];
		$email = $_SESSION["email"];
		// header('location:form.php');
	}
	else
	{
		header('location:index.php?expired session please login back');
		// $userName = $_SESSION["userName"]; $userRole = $_SESSION["userRole"];
		}
?>
<?

require ("_common/global.php");
require ("_common/conn.php");
//require ("_common/function.php");
require ("_common/check_session.php");
?>
<?php
/* Attempt MySQL server connection. Assuming you are running MySQL
server with default setting (user 'root' with no password) */
$link = mysqli_connect("localhost", "dvsvigov_vacc", "DVSvacdos123", "dvsvigov_vacdos");
 
// Check connection
if($link === false){
    die("ERROR: Could not connect. " . mysqli_connect_error());
}
// Escape user inputs for security
// $fName = mysqli_real_escape_string($link, $_POST['fName']);
$name = mysqli_real_escape_string ($link, $_POST['name']);
$email = mysqli_real_escape_string($link, $_POST['email']);
$post = mysqli_real_escape_string($link, $_POST['post']);
$phone = mysqli_real_escape_string($link, $_POST['phone']);
$pass = mysqli_real_escape_string($link, $_POST['pass']);
$role = mysqli_real_escape_string($link, $_POST['role']);
$status = mysqli_real_escape_string($link, $_POST['status']);
$addedby = mysqli_real_escape_string($link, $_POST['addedby']);

// attempt insert query execution
$sql = "INSERT INTO user (name, email, post, phone, pass, role, status, addedby) 
VALUES ('$name', '$email', '$post', '$phone', '$pass', '$role', '$status', '$addedby' )";
mysqli_query($link, $sql);
header('location: usermanage.php');
mysqli_close($link);
?>
