Hi,
I'm working on some cms for gamers and teams, wars, etc...
But i have problem how to separate html from php.
For example i want make all includes so when u make template u just include file in and thats it
for example.
Now i have
index.php ( here will be all includes, css, js )
login.php ( here will be checks for user data )
FOLDER named Templates -> login.html
So now i need when i finish all in login.php to call data from html file and in html file just to be variables from login.php
like
I'm working on some cms for gamers and teams, wars, etc...
But i have problem how to separate html from php.
For example i want make all includes so when u make template u just include file in and thats it
Code:
<?php include 'latest_news'; ?>
Now i have
index.php ( here will be all includes, css, js )
login.php ( here will be checks for user data )
FOLDER named Templates -> login.html
So now i need when i finish all in login.php to call data from html file and in html file just to be variables from login.php
like
Code:
<?php
if (!defined('ACCESS')) {
die('Forbidden!');
}
if ($general->is_logged() === true) {
include 'inc/logged.html';
} else {
// login form
if (isset($_POST['login']))
{
$username = $_POST['username'];
$password = $general->safepass($_POST['password']);
$last_login_date = time();
$ip = $general->get_ip();
if (empty($username) || empty($password))
{
$error = $lang['login_error_user'];
}
else
{
$login = $users->login($username, $password);
// cookie login
if (isset($_POST['stay_logged']))
{
if ($login)
{
$user_id = $login['id'];
$expire = time()+60*60*24*30;
$rand = hash('sha512', mt_rand());
setcookie('token', $rand, $expire);
setcookie('username', $login['username'], $expire);
setcookie('id', $login['id'], $expire);
$update_login_data = $users->update_cookie_login($last_login_date, $ip, $rand, $user_id);
header('Location: index.php');
exit();
}
else
{
$error = $lang['login_error_data'];
}
}
// session login
else
{
if ($login)
{
$_SESSION['id'] = $login['id'];
$_SESSION['username'] = $login['username'];
$user_id = (int)$_SESSION['id'];
$update_login = $users->update_user_ip_login($last_login_date, $ip, $user_id);
header('Location: index.php');
exit();
}
else
{
$error = $lang['login_error_data'];
}
}
}
}
}
?>
Code:
<form action="" method="POST"> <input type="text" name="username" placeholder="<?php echo $user?>"> <input type="password" name="password" placeholder="<?php echo $pass?>"> <input type="submit" name="login" value="<?php echo $login_button?>"> </form>