not sure whether this is the right place to post but still, I have a simple logon script for my website written in php.
login.php
<html>
<head>
<title>Website Administration</title>
</head>
<body background='./bg.jpg'>
Website >> Administration
<form method="post" action="index2.php">
<p align="left">
<b>
</b><u><b>Login:</b></u></p>
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="220">
<tr>
<td width="10%" height="119">Password:<input type="password" name="password" size="20"></p>
</td></tr>
<tr>
<tr>
<td width="10%" height="27"></td>
<td width="90%" height="27"><input type="submit" name="submit" value="submit" />
</td>
</tr>
</table>
<p> <br />
</p>
</form>
<p><a href="index.php">back</a></p>
</body>
</html>
index2.php
<?
session_start();
?>
<?php
if (strstr($_POST["password"], "password")) {
?>
<body background='bg.jpg'>
Website Administration
<p> </p>
<a href="addnews.php">Add News</a>
<?
} else {
die ("you are unauthorized. Please log on <a href='index.php'>here!</a>"); }
?>
Ok, now on my addnews.php page I want it to recheck that username is logged in (unless a user manually types in addnews.php on browser and mucks up site!)
addnews.php
<html>
<head>
<title>Update News Items</title>
</head>
<body background='bg.jpg'>
Website >> Add News
<?php
if (strstr($_POST["password"], "password")) {
?>
<form method="post" action="editNews.php">
<p align="left">
<b>
</b><u><b>Enter News Item</b></u></p>
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="220">
<tr>
<td width="10%" height="119">News:</td>
<td width="90%" height="119"> <textarea rows="5" name="news" cols="27"></textarea></td>
</tr>
<tr>
<td width="10%" height="1"><center></center></td>
<td height="1"><input type="hidden" name="date" value="<?php
// prints something like 15/12/04
echo date("d/m/y");
?>" /></td></tr>
<tr>
<td width="10%" height="27"></td>
<td width="90%" height="27"><input type="submit" name="submit" value="submit" />
</td>
</tr>
</table>
<p> <br />
</p>
</form>
<p><a href="index.php?act=home">back</a></p>
</body>
</html>
<?
} else }
die ("you are unauthorized. Please log on again!"); }
?>
This doesn't work. Anyone any ideas why?
Basically, I want this add news page to make sure the username was logged in from index2.php
Any ideas?