I´m all new on this and is ready some php & mysql books. but right now I´m working on the user register system.
If I make a variable on one page and include it on a other page how can I then call that variable?
<?php
session_start();
$exceptions = array('register','login','activation');
$page = substr(end(explode('/', $_SERVER['SCRIPT_NAME'])), 0, -4);
$databse = mysql_connect('localhost', 'root', 'My_pass');
mysql_select_db('user_system', $databse);
$path = dirname(__FILE__);
include("{$path}/inc/user.inc.php");
if (isset($_COOKIE['username'], $_COOKIE['password']) && isset($_SESSION['username']) === false){
if (vaild_credentials($_COOKIE['username'], $_COOKIE['password'])){
$_SESSION['username'] = htmlentities($_COOKIE['username']);
setcookie('username', $_COOKIE['username'], time() + 604800);
setcookie('password', $_COOKIE['password'], time() + 604800);
}
}
if (in_array($page, $exceptions) === false){
if(isset($_SESSION['username']) === false){
header('location: login.php');
die();
}
}
?>
This is my init.inc.php file best regards
Wizzuriz