Hi. I am making a members area with session-protected pages. I have the sessions and stuff figured out, but I keep getting parse errors and the like in this code:
<?php
session_start();
if (isset($_POST['user']) && isset($_POST['password']))
{
// if the user has just tried to log in
$user = $_POST['user'];
$password = $_POST['password'];
$cryptpass = md5($password);
mysql_connect ("localhost", "jutm543", "password") or die ('I cannot connect to the database.');
mysql_select_db ("jutm543_members");
$User = mysql_query("SELECT username,password FROM users WHERE username = '$user' AND password = '$cryptpass'");
if(mysql_num_rows($User) >0)
{
// if they are in the database register the session
$_SESSION['auth'] = "yes";
}
else {
$_SESSION['auth'] = "no";
}
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Chipspot :: A Place to Keep My Stuff</title>
<base target="view">
<style type="text/css">
<!--
body {color: #bcbcbc; font: normal xx-small tahoma,verdana,arial}
td {color: #bcbcbc; font: normal xx-small tahoma,verdana,arial}
#form {color: #bcbcbc; font: normal xx-small tahoma,verdana,arial}
A:visited {COLOR: #FFFFFF; TEXT-DECORATION: none}
A:link {COLOR: #FFFFFF; TEXT-DECORATION: none}
A:active {COLOR: #FFFFFF; TEXT-DECORATION: none}
A:hover {COLOR: #FFFFFF; TEXT-DECORATION: underline}
.style1 {color: #CCCCCC}
.style2 {color: #FFFFFF}
-->
</style>
</head>
<body bgcolor="#000000" text="#FFFFFF" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF">
<center>
<table width="100%" height="100%">
<td align="center">
<table border="0" width="850" cellpadding="0" cellspacing="0" bordercolor="#6F7D84">
<tr>
<td height="15" colspan="2" align="center" bordercolor="#889399"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="850" height="105">
<param name="movie" value="top.swf">
<param name="quality" value="high">
<embed src="top.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="850" height="105"></embed>
</object></td>
</tr>
<tr>
<td width="150" height="400" align="center" bgcolor="#011470"><blockquote>
<p align="left">
<a href="index.html" target="_parent">Home</a><br>
<br>
<a href="news.php" target="_parent">News</a><br>
<br>
Projects<br>
<br>
Scripts<br>
<br>
<a href="login.php" target="_parent">Login<br><br>
</a>Pictures<br><br>
Forum</p>
</blockquote></td>
<td width="700" align="center" bgcolor="#1C006C"><div align="center">
<blockquote>
<p class="style1">
<?php
if ($_SESSION['auth'] = "yes")
{
echo 'You are now logged in. <br />';
echo '<a href="logout.php">Log out</a><br />';
echo '<a href="members.php">Continue</a>';
}
if ($_SESSION['auth'] = "no")
{
// if they've tried and failed to log in
echo 'Either your username or password were incorrect, or you could not be logged in at this time.<br />';
}
else
{
// they have not tried to log in yet or have logged out
echo 'You are not logged in.<br />';
// provide form to log in
echo '<form method="post" action="login.php">';
echo '<table>';
echo '<tr><td>Username:</td>';
echo '<td><input type="text" name="user"></td></tr>';
echo '<tr><td>Password:</td>';
echo '<td><input type="password" name="password"></td></tr>';
echo '<tr><td colspan="2" align="center">';
echo '<input type="submit" value="Log in" target="_parent"></td></tr>;
echo '</table></form>';
}
?>
<br><br><br>
</p>
</blockquote>
</div></td>
</tr>
<tr bordercolor="#000000">
<td height="15" colspan="2" align="center"><img src="images/divider_bottom.jpg" width="100%" height="13"></td>
</tr>
</table>
</table>
</center>
</body>
</html>
Please help, thanks.
Selatos, the members area code: See any problems?
<?php
session_start();
if($_SESSION['auth'] == "yes") {
echo '<html>';
echo '<head>';
echo '<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">';
echo '<title>Chipspot :: A Place to Keep My Stuff</title>';
echo '<base target="view">';
echo '<style type="text/css">';
echo '<!--';
echo 'body {color: #bcbcbc; font: normal xx-small tahoma,verdana,arial}';
echo 'td {color: #bcbcbc; font: normal xx-small tahoma,verdana,arial}';
echo '#form {color: #bcbcbc; font: normal xx-small tahoma,verdana,arial}';
echo 'A:visited {COLOR: #FFFFFF; TEXT-DECORATION: none}';
echo 'A:link {cOLOR: #FFFFFF; TEXT-DECORATION: none}';
echo 'A:active {COLOR: #FFFFFF; TEXT-DECORATION: none}';
echo 'A:hover {COLOR: #FFFFFF; TEXT-DECORATION: underline}';
echo '.style1 {color: #CCCCCC}';
echo '.style2 {color: #FFFFFF}';
echo '-->';
echo '</style>';
echo '</head>';
echo '<body bgcolor="#000000" text="#FFFFFF" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF">';
echo '<center>';
echo '<table width="100%" height="100%">';
echo ' <td align="center">';
echo '<table border="0" width="850" cellpadding="0" cellspacing="0" bordercolor="#6F7D84">';
echo ' <tr>';
echo ' <td height="15" colspan="2" align="center" bordercolor="#889399"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="850" height="105">';
echo '<param name="movie" value="top.swf">';
echo '<param name="quality" value="high">';
echo '<embed src="top.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="850" height="105"></embed>';
echo ' </object></td>';
echo ' </tr>';
echo ' <tr>';
echo ' <td width="150" height="400" align="center" bgcolor="#011470"><blockquote>';
echo ' <div align="left">';
echo ' <p><a href="index.html" target="_parent">Home</a><br>';
echo ' <br>';
echo ' <a href="news.php" target="_parent">News</a><br>';
echo ' <br>';
echo ' Projects<br>';
echo ' <br>';
echo ' Scripts<br>';
echo ' <br>';
echo ' <a href="login.php" target="_parent">Login<br>';
echo ' <br>';
echo ' </a>Pictures<br>';
echo ' <br>';
echo ' Forum<br>';
echo ' <br>';
echo ' </p>';
echo ' </div>';
echo ' </blockquote></td>';
echo ' <td width="700" align="center" bgcolor="#1C006C"><div align="center">';
echo ' <blockquote>';
echo ' <div align="center">Welcome to the members only area! Thank you for logging in.<br /><br />';
echo ' <a href="logout.php">Logout</a>';
echo ' </div>';
echo ' </blockquote>';
echo ' </div></td>';
echo ' </tr>';
echo '<tr bordercolor="#000000">';
echo ' <td height="15" colspan="2" align="center"><img src="images/divider_bottom.jpg" width="100%" height="13"></td>';
echo ' </tr>';
echo '</table>';
echo '_</table>';
echo '</center>';
echo '</body>';
echo '</html>';
} else {
echo 'You are not logged in<br />';
echo '<a href="login.php">Log in </a>';
?>