murdocsvan
Web Programmer
- Messages
- 896
- Location
- Surrey, UK
Awesome, thanks. Can you see anything i've missed out?
<?php
session_start();
if(!isset($_SESSION['logged'))
{
header("location:login/main_login.htm");
}
?>
if($count==1)
{
// Register $myusername, $mypassword and redirect to file "login_success.php"
$_SESSION['logged'] = "yes";
header("location:login_success.php");
}
else
{
echo "Error: Wrong Username or Password";
}
I was also reading about sessions and i read that the old session has been depracated by $_SESSION. I've tried changing it, but i've found i've got a parse error when i request the session on the other pages. No problem with registering it though.
This is the code that gives me an error:
PHP:<?php session_start(); if(!isset($_SESSION['logged')) { header("location:login/main_login.htm"); } ?>
And this is the code that sets the variable on the check_login page:
PHP:if($count==1) { // Register $myusername, $mypassword and redirect to file "login_success.php" $_SESSION['logged'] = "yes"; header("location:login_success.php"); } else { echo "Error: Wrong Username or Password"; }
Lol it probably isn't very secure.
Thanks in advanced.
//Check user is logged in
session_start();
if(!isset($_SESSION['logged']))
{
header("location:login/main_login.htm");
}
<?php
session_start();
if (isset ($_SESSION['logged'])) {
// do logged in stuff
} else {
// not logged in
header('location: login/main_login.html');
}
?>
<?php
session_start();
if (isset ($_SESSION['logged'])) {
echo '<b>Multiple</b>
<i>lines of</i>
<u>wonderful HTML!</u>';
} else {
// not logged in
header('location: login/main_login.html');
}
?>
<?php
session_start();
if (isset ($_SESSION['logged'])) {
// do logged in stuff
?>
You've ended the PHP tags, so do your junk here.
<?php
// then you can restart here. PHP doesn't care
} else {
// not logged in
header('location: login/main_login.html');
}
?>