Question
Mysql/PHP some problem in retrieving data from the database
Hi,
Hi I am new to php and dreamweaver. I am using dream weaver MX 2004 and the latest version of MySQL. I am making a login page and using the default server behavior of Dream weaver for it it there is a problem. The problem is that I have two types of users: admin and simple user. Now in the default server behavior we have only two options if it succeeds go one page other wise go to another and in my situation I have 3 pages, one for admin, one for simple users, and one if the users is unable to login. Following is the code I had edited so far by now.
mysql_select_db($database_connectDB1, $connectDB1);
$sql = mysql_query("SELECT username,password,type FROM users WHERE username = '$username'");
$fetch_em = mysql_fetch_array($sql);
//$numrows = mysql_num_rows($sql);
if($fetch_em["type"] == "Admin")
{
$MM_redirectLoginSuccess = "admin.php";
}
else if($fetch_em["type"] == "User")
{
$MM_redirectLoginSuccess = "nuser.php";
}
$MM_redirectLoginFailed = "index.php";
(username is primary key and there is no caps problem with the word Admin or User)
but it is not working. I am really stuck now and unable to do it. Can any please tell me where I am wrong or tell me any other easier way to do the same thing. Even a little hel will be really appreciated.
Thanks in advance.

Hi I am new to php and dreamweaver. I am using dream weaver MX 2004 and the latest version of MySQL. I am making a login page and using the default server behavior of Dream weaver for it it there is a problem. The problem is that I have two types of users: admin and simple user. Now in the default server behavior we have only two options if it succeeds go one page other wise go to another and in my situation I have 3 pages, one for admin, one for simple users, and one if the users is unable to login. Following is the code I had edited so far by now.
mysql_select_db($database_connectDB1, $connectDB1);
$sql = mysql_query("SELECT username,password,type FROM users WHERE username = '$username'");
$fetch_em = mysql_fetch_array($sql);
//$numrows = mysql_num_rows($sql);
if($fetch_em["type"] == "Admin")
{
$MM_redirectLoginSuccess = "admin.php";
}
else if($fetch_em["type"] == "User")
{
$MM_redirectLoginSuccess = "nuser.php";
}
$MM_redirectLoginFailed = "index.php";
(username is primary key and there is no caps problem with the word Admin or User)
but it is not working. I am really stuck now and unable to do it. Can any please tell me where I am wrong or tell me any other easier way to do the same thing. Even a little hel will be really appreciated.
Thanks in advance.
