Hi
I'm trying to write a little code that checks if my user is logged in before using the page:
check.php:
<?php
if(!isset($_SESSION['usernama'])){
echo "<div align='center'>You have to log in first!</div><br/>";
exit;}
?>
En this is the script I'm trying to protect: change.php
<?php
include ('include/session.php');
include ('config.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 transitional //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Change password</title>
</head>
<body >
<?php
require ('check.php');
echo "<form action='change2.php' method='post'>
<input type='hidden' name='doen' value='change'>
<table border='0' cellspacing='0' cellpadding='0' align='center'>
<tr>
<td colspan='2' align='center'> <strong>Change password</strong></td>
</tr>
<tr>
<td > New password</td>
<td align='center'><input type ='password' class='bginput' name='password'></td>
</tr>
<tr>
<td > Re-Enter password</td>
<td align='center'>
<input type ='password' class='bginput' name='password2' ></td>
</tr>
<tr>
<td colspan=2 align='center'><input type='submit' value='change'><input type='reset' value='Change'></td>
</tr>
";
echo "</table>";
?>
But the problem is, that when I go to the change.php- file, that the browser shows the warnign: "You have to log in first", so far so good,
but he also shows the form! So, that's not what I want. I think it has something to do with the "exit;" in the check.php. Is there an other way the write this code?
Thank you!!