Hello, I'm having bit trouble about this thing I made
I'm trying to redirect the page on 'changing the password' with the use of ACCT_CODE column from member table of alumni database but I can't seem to redirect it. can someone please help me and teach me where did I gone wrong with this?
P.S.
I've commented the line where I guess it started my problem up to the last line. (because whenever I add that important code to redirect to changepassword it always give me error
on this thing:
"Parse error: syntax error, unexpected T_ELSE in E:\xampp\htdocs\site\checklogin.php"
I'm using '0's and '1's to check if the user needs to change password(using the ACCT_CODE column), if that also helps to solve my problem.
Thanks for reading I hope you can help me with this
<?php session_start();
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="3214"; // Mysql password
$db_name="alumni"; // Database name
$tbl_name="member"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
//-----------------
$_SESSION['current_username']=$myusername;
//-----------------
//This is where the problem starts
$query="SELECT ACCT_CODE FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
if($query==0){
{header("location: changepassword.php");}
else
{header("location:login_success.php");}
}
//This is where the problem ends
else {
echo "Wrong Username or Password";
}
?>