I am getting the "Parse error: syntax error, unexpected '{' in /Applications/MAMP/htdocs/pwtest.php on line 124" message.
I have counted all my curly braces and the '{' ='}'
What is another way to approach solving this problem?
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
if (isset($_SESSION['member_name'])) {
echo ('<a href="logout.php" class="style5">Logout</a>');
} else {
echo (' <a href="login.php">Login</a>');
}
?>
</span>
<span class="social">
Follow us on <a href="http://www.facebook.com/pages/Beatles-White-Album-Registry/125094678135?v=wall&viewas=1035188108" target="_blank"><img src="/images/facebook-small.gif" alt="Facebook" /></a>
<a href="http://twitter.com/whitealbumreg" target="_blank"><img src="/images/twitter-small.gif" width="20" height="20" alt="Twitter" /></a></span>
<!-- AddThis Button BEGIN -->
<a href="http://www.addthis.com/bookmark.php?v=250&pub=bluetonic" onmouseover="return addthis_open(this, '', '[URL]', '[TITLE]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><img src="http://s7.addthis.com/static/btn/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/></a>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js?pub=bluetonic"></script>
<!-- AddThis Button END -->
</div>
<!-- end #header -->
<div id="lp"><img src="/images/lp_half_index.jpg" alt="White Album vinyl" width="322" height="670" /></div>
<div id="nav">
<?php
if (isset($_SESSION['member_name'])) {
echo ("<a href='register.php' onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('Image1','','/images/header_reg2.jpg',1)\"><img src='/images/header_reg1.jpg' name='Image1' width='173' height='45' border='0' id='Image1' alt='register image' /></a>");
} else {
echo ("<a href='join.php' onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('Image1','','/images/header_reg2.jpg',1)\"><img src='/images/header_reg1.jpg' name='Image1' width='173' height='45' border='0' id='Image1' alt='register image' /></a>");
}
?>
<a href="/stats.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('stats','','/images/header_stats2.jpg',1)"><img src="/images/header_stats1.jpg" alt="Beatles White Album stats" name="stats" width="89" height="45" border="0" id="stats" /></a>
<a href="inside.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('inside','','/images/header_inside2.jpg',1)"><img src="/images/header_inside1.jpg" alt="Inside the White Album" name="inside" width="200" height="45" border="0" id="inside" /></a>
<a href="help.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('help','','/images/header_need2.jpg',1)"><img src="/images/header_need1.jpg" alt="White Album Registry need your help!" name="help" width="125" height="45" border="0" id="help" /></a>
<a href="/index.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('home','','/images/header_home2.jpg',1)"><img src="/images/header_home1.jpg" alt="White Album Registry home" name="home" width="66" height="45" border="0" id="home" /></a>
</div>
<?php
require_once('connect.php');
// Ensure fields are filled out.
if (isset($_POST['submit'])) {
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)
or die('Error connecting to MySQL server');
$member_name = mysqli_real_escape_string($dbc, trim($_POST['member_email']));
$output_form = 'no';
echo $member_name;
if (empty($member_email) {
/* We know $member_name is blank*/
echo '<h2><font color="red">Oops! You forgot to input your email!</font></h2><br />';
$output_form = 'yes';
}
} else {
$output_form = 'yes';
}
if (!empty($member_email) {
$query = "SELECT member_email FROM whitealbumreg.members WHERE member_email = '$_POST[member_email]'";
$result = mysqli_query($dbc, $query);
$num_rows = mysqli_num_rows($result);
if ($num_rows == 1) {
function randompassword($len)
{
$pass = '';
$lchar = 0;
$char = 0;
for($i = 0; $i < $len; $i++)
{
while($char == $lchar)
{
$char = rand(48, 109);
if($char > 57) $char += 7;
if($char > 90) $char += 6;
}
$pass .= chr($char);
$lchar = $char;
}
return $pass;
}
$active_code=randompassword(8);
$query2 = "UPDATE `whitealbumreg`.`members` SET `member_password`='$active_code' WHERE `members`.`member_id` = '$_POST[member_name]' LIMIT 1";
mysqli_query($dbc, $query2)
or die('Error querying database.');
echo ('<h2>You should receive an email shortly with your new password. Simply click the link and follow the instructions. Thank you for your interest in the White Album Registry.</h2><br />');
//define the receiver of the email
$to = '$_POST[member_email]';
//define the subject of the email
$subject = 'From The White Album Registry';
//define the message to be sent. Each line should be separated with \n
$message = "Your new password is $active_code \n";
"Please click the link below.\n";
"http://www.whitealbumregistry.com/login.php";
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: admin@whitealbumregistry\r\nReply-To: admin@whitealbumregistry.com";
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
echo $mail_sent ? "Mail sent" : "Mail failed";
$output_form = 'yes';
mysqli_close($dbc);
}
}
if ($output_form == 'yes') {
?>
<!-- InstanceBeginEditable name="mainContent" -->
<div id="mainContent">
<h1>Forgot Password</h1>
A new password will be generated for you and sent to the email address<br>
associated with your account, all you have to do is enter your
username.<br /><br />
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST">
<b>Email:</b> <input type="text" name="member_email" maxlength="30" value="<?php if (!empty($member_name)) echo ($member_name); ?>">
<input type="submit" value="Get New Password">
</form>
</p>
</div>
<?php
}
?>