I hope I can explain this properly :queasy:
I have the following code stored in a MySQL database.
<?php
if (isset($POST['frm_username'])) {
if ($POST['frm_username'] == 'abasel' and $POST['frm_password'] == '12345') {
$SESSION['authorized'] = TRUE;
}
}
if (isset($REQUEST['logout'])) {
unset($session['authorized']);
}
if (isset($SESSION['authorized'])) {
?>
<p>Logged in</p>
<p><a href="<?php echo $SERVER['PHP_SELF']; ?>?>logout=1">Log Out</a></p>
<?php
} else {
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table width="310" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="104"><div align="center">Username</div></td>
<td width="206"><div align="center">
<input name="frm_username" type="text" id="frm_username">
</div></td>
</tr>
<tr>
<td><div align="center">Password</div></td>
<td><div align="center">
<input name="frm_password" type="password" id="frm_password" size="15" maxlength="8">
</div></td>
</tr>
<tr>
<td><div align="center">
<p> </p>
</div></td>
<td><p> </p></td>
</tr>
<tr>
<td><div align="center">
<p><a href="#" class="comment">Register a New Account</a></p>
<p><a href="#" class="comment">Forgotten Login Details</a></p>
</div></td>
<td valign="middle"><div align="center">
<input name="frm_login" type="submit" id="frm_login" value="Login">
</div></td>
</tr>
</table>
</form>
<?php
}
?>
It is pulled into the wide site via the following URL:
http://tbcol.internetlinked.com/index.php?id=9
As you'll see, I'm just experiementing at present. What I can't understand is that the IF statements don't seem to be doing anything i.e. both the true and false conditions are running. Also when I go to view source, I can see all the PHP code???
I've sure it's something really simple but just can't see it.
The following is the code within index.php that fetches the above code
<?php
if(isset($GET['id']))
{
$menu = "{$GET['id']}";
$query = "SELECT id, title, content, image FROM tblpages WHERE id = '{$_GET['id']}'";
}
else
{
$menu = "1";
$query = "SELECT id, title, content, image FROM tblpages WHERE id='1'";
}
$result = mysql_query($query) or die('Error, query failed');
WHILE ($entry = mysql_fetch_array($result, MYSQL_ASSOC))
{
$backgroundimage = $entry['image'];
echo "<h1>";
echo "{$entry['title']}";
echo "</h1>";
echo "{$entry['content']}";
}
include '/home/intern/public_html/includes/closedb.php';
?>