Jump to content

[SOLVED] } else { error


chriscloyd

Recommended Posts

this is the error im getting

 

Parse error: syntax error, unexpected T_ELSE in /home/cpc/public_html/process/login.php on line 34

 

this is my code can someone help me there

 

<?php
session_start();
mysql_connect('localhost','*******','*******');
mysql_select_db('*******');
$username = mysql_real_escape_string($_POST['username']);
if ($username == NULL) {
$error = 1;
$_SESSION['*******'] = 'No username entered.';
} 
$password = mysql_real_escape_string($_POST['password']);
$password = md5($password);
if ($password == NULL) {
$error = 1;
$_SESSION['*******'] = 'No password entered.';
}
if ($error == 1) {
header("Location: ../index.php");
} else {
$check_username = mysql_query("SELECT * FROM users WHERE username = '".$username."'");
$num_users = mysql_num_rows($check_users);
if ($num_users > 0) {
	$user_info = mysql_fetch_assoc($check_username);
	if ($user_info['password'] == $password);
		$_SESSION['*******'] = $username;
		$check_admin = mysql_query("SELECT * FROM admins WHERE uid = '".$user_info['uid']."'");
		$num_admins = mysql_num_rows($check_admin);
		if ($num_admins > 0) {
			$_SESSION['*******'] = 'yes';
		}
	} else {
		$_SESSION['*******'] = 'Incorrect information.';
		header("Location: ../index.php");
	}
} else {
	$_SESSION['*******'] = 'No account for that username.';
	header("Location: ../index.php");
}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/135613-solved-else-error/
Share on other sites

I think you mean like

 

<?php
session_start();
mysql_connect('localhost','*******','*******');
mysql_select_db('*******');
$username = mysql_real_escape_string($_POST['username']);
if ($username == NULL)
{
   $error = 1;
   $_SESSION['*******'] = 'No username entered.';
} 
$password = mysql_real_escape_string($_POST['password']);
$password = md5($password);
if ($password == NULL)
{
   $error = 1;
   $_SESSION['*******'] = 'No password entered.';
}
if ($error == 1)
{
   header("Location: ../index.php");
}
else{
   		$check_username = mysql_query("SELECT * FROM users WHERE username = '".$username."'");
   		$num_users = mysql_num_rows($check_users);
   		if ($num_users > 0)
	   {
      			$user_info = mysql_fetch_assoc($check_username);
      			if ($user_info['password'] == $password)
      			{
         			$_SESSION['*******'] = $username;
         			$check_admin = mysql_query("SELECT * FROM admins WHERE uid = '".$user_info['uid']."'");
         			$num_admins = mysql_num_rows($check_admin);
         			if ($num_admins > 0)
		 		{
            			$_SESSION['*******'] = 'yes';
         			}
         		}
		 	else{
         				$_SESSION['*******'] = 'Incorrect information.';
         				header("Location: ../index.php");
      				}
   			}
		else{
      				$_SESSION['*******'] = 'No account for that username.';
      				header("Location: ../index.php");
   				}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/135613-solved-else-error/#findComment-706554
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.