Jump to content

Whats wrong with this?


Brenton

Recommended Posts

<?php
require ('globals.php');

if ($_GET['act'] == "submit") {
// For register_global on PHP settings
$username = $_POST['username'];
$password = $_POST['password'];

// Check for empty fields
if (empty($username) || empty($password) ) {
	die ("Error! Please enter your username and password, they are both required. <br /> <a href='$PHP_SELF?'>Go Back</a>");
}

// Authenticate user credentials
$qChk = "select username from users where username='$username' and password='$password' and status='Y' ";
$rsChk = mysql_query($qChk);

$rowCount = mysql_num_rows($rsChk);

if ($rowCount !='1') // query did not return 1 row, user is not verified {
	die ("Error. Your password does not match your username or your account was not yet activated. Please try again.");
}

// User is now logged in, lets give them a cookie.
setcookie ("member",$username,time()+1957240,"/");
setcookie ("ip",$REMOTE_ADDR,time()+1957240,"/");
$member = $username;
session_register("member");

// Update Login timer
$qUpdate = "update users set login = now() where username='$username' and password='$password' and active='Y' ";
$rsUpdate = mysql_query($qUpdate);

if ($rsUpdate) {
	header("Location: welcome.php"); // redirects members to a welcome member page
}
}

else {
echo <<<END
<form action='$PHP_SELF?act=submit' method='post'>
<center><table width='300px'><tr><td align='left'>Username:</td><td align='right'> <input type='text' name='username' maxlength='15'></td></tr>
<tr><td align='left'>Password:</td> <td align='right'><input type='password' name='password' maxlength='25'></td></tr></table>
<input type=submit value=login name=login>
</form></center>
END;
}
?>

Whats wrong with my login script?

I get a Parse error: syntax error, unexpected '}' in /home/brenton/public_html/nordaea/login.php on line 37

 

Why's it happening?

How do i fix?

Link to comment
Share on other sites

This bottom } is 'orphaned' meaning it either doesn't belong and it's one too many or you had it there to close an if statement that isn't set up right.

 

	if ($rsUpdate) {
	header("Location: welcome.php"); // redirects members to a welcome member page
}
}

Link to comment
Share on other sites

it's true about the braces being "orphaned," but the specific line where you go wrong is:

 

<?php
if ($rowCount !='1') // query did not return 1 row, user is not verified {
	die ("Error. Your password does not match your username or your account was not yet activated. Please try again.");
}
?>

 

you're commenting out the opening brace on the row count line.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.