heres what going on. i have an index page with a login area. when you login, it posts to login.php, which then tries to authenticate or give an accurate reason why it didn't authenticate the user's login info. i am using sessions to transmit variables back into the site if it is successful, which can then be sent along with the user as they browse. when the settings section comes up they can view their profile and change various aspects of it. the variable 'prov' is also for serving up local news to users.
here is the code:
<?php
session_start();
header("Cache-control: private");
$user = $POST['name'];
$pass = $POST['pwd'];
include ('db.123');
// checkin if the user exists
$sql_user_check = "SELECT * FROM users WHERE username='$user'";
$result_name_check = mysql_query($sql_name_check);
$usersfound = mysql_num_rows($result_name_check);
// if doesn't exist, it'll change the errormsg and close the connection
if ($usersfound == "0") {
$SESSION['msg'] = "User $SESSION['username'] not found.";
mysql_close($dbc);
} else {
// if does exist, grabs users pass and compares to input
$sql_pass_reg = "SELECT password FROM users WHERE username='$user'";
$result_pass_reg = mysql_query($sql_pass_reg);
// checks for match - no match, chg errormsg and close connection
if ($result_pass_reg != $pass) {
$SESSION['msg'] = "Invalid password. Try again.";
mysql_close($dbc);
// checks for match - match, put user info into session variables for settings
} elseif ($result_pass_reg == $pass) {
$result_user_info = mysql_query($sql_user_check);
$user_info = mysql_fetch_array($result_user_info);
$SESSION['username'] = $user_info['username'];
$SESSION['password'] = $user_info['password'];
$SESSION['name'] = $user_info['name'];
$SESSION['prov'] = $user_info['prov'];
$SESSION['style'] = $user_info['style'];
$SESSION['media'] = $user_info['media'];
$SESSION['hist'] = $user_info['hist'];
$SESSION['infl'] = $user_info['infl'];
$SESSION['open'] = $user_info['open'];
$SESSION['webs'] = $user_info['webs'];
$SESSION['email'] = $user_info['email'];
$SESSION['photo'] = $user_info['photo'];
$SESSION['paid'] = $user_info['paid'];
$SESSION['msg'] = "Welcome back $SESSION['name'].";
mysql_close($dbc);
// otherwise this way ill be notified if i fucked up
} else {
$SESSION['msg'] = "An unknown error has occured. Please contact the webmaster ASAP.";
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<?php include("includes/meta.inc"); ?>
<title>HearHere ASP Canada - Home</title>
<?php include("includes/basehref.inc"); ?>
<link rel="stylesheet" href="scripts/global.css">
<script language="javascript" src="scripts/preload.js"></script>
</head>
<body onLoad='imageLoad()'><center>
<table border="0" cellspacing="0" cellpadding="0" width="750">
<tr><td bgcolor="#FFFFFF" height="105" width="750"><img src="img/head-mysettings.jpg" height="105" width="750" alt="HearHere ASP - My Settings" /></td></tr>
<tr><td bgcolor="#CCCCCC" background="img/bg-main.jpg" height="30" width="750">
<?php include("includes/links.inc"); ?></td></tr>
<tr><td bgcolor="#333333" background="img/bg-bread.jpg" height="25" width="750" align="left" valign="middle">
<div class="bread">home > <a class="bread" href="index.php">take a tour</a> | <a class="bread" href="index.php">register</a> | <a class="bread" href="index.php">logout</a></div></td></tr>
<tr><td bgcolor="#CCCCCC" background="img/bg-main.jpg" height="100%" width="750" align="left" valign="top">
<div class="main">
<table border="0" cellspacing="0" cellpadding="0" width="690">
<tr><td width="480" align="left" valign="top">
<h1 class="main">Home</h1>
<p>Welcome to HearHere, a spot for artists, by artists. This website is a wealth of resources for beginning and aspiring recording artists, and we can help artists achieve that ultimate goal. Although we offer resources and services to help you on your way, community is also a very important part of this website. You will be able to communicate with fellow aspiring artists, share ideas and thoughts, and offer your own resources to the rest of the community.</p>
<p>Given the extensiveness and value of the resources offered here, HearHere operates on a two-tiered system. As a free member, you will still be able to take part in the community and view a certain amount of our resources offered. Paying members, however, receive a fair amount of perks. These perks include (but aren't limited to):</p>
<ul><li>full and unrestrained access to HearHere's resource bank</li>
<li>ability to discuss restricted articles with other paying members</li>
<li>ability to share songs with fellow members</li>
<li>ability to sell your merchandise online through our member store</li></ul>
<p>Although there are a great number of perks for paying members, we have to stress that this site remains an excellent resource for free members, and encourage anyone and everyone with interest in music or the recording industry to sign up. It's free, and the bigger the community, the more helpful we can be to you as an artist.</p>
<p>Payment system for paying members is a monthly fee paid by credit card. Upon the date of renewal, members CAN choose to not renew and revert back to free membership status. If you're interested in becoming a paying member right away, please feel free to take a tour of the website, and have a better look at what's available. If you'd like to ponder it further, feel free to sign up right now and see what the site has to offer free members.</p></td>
<td width="200" align="right" valign="top">
<?php
if (!$SESSION['username']) {
include ('includes/login.php');
echo $_SESSION['msg'];
} else {
include ('includes/login.php');
} ?>
</td></tr></table>
</div></td></tr>
<tr><td bgcolor="#CCCCCC" background="img/bg-main.jpg" width="750" align="center">
<div class="copy">Copyright © 2003 HearHere ASP Canada</div></td></tr>
<tr><td height="10" width="750"><img src="img/footer.jpg" height="10" width="750" alt=" " /></td></tr></table>
</body></html>
i consistently receive the error "Parse error: parse error, unexpected $ in (login.php location here) on line 89"
i have created the variable $_SESSION['username'] earlier, haven't i? so why on earth is it considered an "unexpected $"? im really going nuts over this, its pissing me off.
thanks for any help you can offer.
andrew