0

Hello, I'm new on using PHP language and using SQL for database.

and yesterday I stumbled upon using the column ACCOUNT_CODE on one of my table in my database as a reference to check if the user that will about to logged in have a premium membership or not..

my ACCOUNT_CODE column is ENUM type but when I use it for IF statement(shown below) in didn't function as I expected, and always redirect the user for the 'premiummember.html' page even if the user only has a default membership account.

Could anyone help me or rather teach me how to figure out some ways to make it check it's membership? I tried to 'google' these things but I can't understand other's codes well since I'm just a beginner to start with

Additional Notes:
The ACCOUNT_CODE only have '0' & '1' entries and '0' as default

Thanks for stopping by and taking time to read this
I'm looking forward to learn more about this stuffs

$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);


if($count==1){
session_register("myusername");
session_register("mypassword");

$_SESSION['current_username']=$myusername; 

//Problem
//this suppose to be the one that will verify the membership type
$query="SELECT ACCOUNT_CODE FROM $tbl_name WHERE username='$myusername'";
$check=mysql_query($query);

if($check == '0'){
  header("location: defaultmember.html");
  }
else{ 
  header("location: premiummember.html");
  }
}
//other codes below this comment line works
else{
echo "Wrong Username or Password";
}
2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by marcus03
1

I am also new to php but the following code works for me.

$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
 
if($count>0){
session_register("myusername");
session_register("mypassword");
 
$_SESSION['current_username']=$myusername; 
 
$row = mysql_fetch_array($result);
$check=$row['ACCOUNT_CODE'];
if($check == '0'){
  header("location: defaultmember.html");
  }
else{ 
  header("location: premiummember.html");
  }
}
//other codes below this comment line works
else{
echo "Wrong Username or Password";
}
0

hey it actually works also for me..thanks bro :)

it proves that I need more practice on making queries XD

anyway your post is very helpful to me

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.