Admin Member PHP Login?

Home > Computers & Internet > Programming & Design > Admin Member PHP Login?

I have my members database table on phpmyadmin online. "members" table has 4 fields (id, username, password, and rights). For rights, there are only two options and that is (admin or user).

I am messing up after "$count = mysql_num_rows ($result);" I tried the below code. It did not work.


$host = "localhost";

$username = "myusername";

$password = "mypwd";

$db_name = "mydb";

$tbl_name = "members";

mysql_connect ($host, $username, $password) or die ("can't connect");

mysql_select_db($db_name) or die (mysql_error ());

$myusername = $_POST ['myusername'];

$mypassword = $_POST ['mypassword'];

$rights = $_POST ['rights'];

$sql = "SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'" rights='$rights'";

$result = mysql_query($sql);

$count = mysql_num_rows ($result);

if($count==1 and $rights='admin') {





elseif ($count==1 and $rights='user') {





else {

echo "Wrong Username or Password";



Admins needs to be directed to admin.php and

users needs to be directed to user.php else

it should say wrong username or password.

Need some help.


You have double quote after $mypassword which will technically end the sql statement;

$sql = "SELECT * FROM $tbl_name WHERE username='$myusername'

and password='$mypassword' and rights='$rights'";

Other Questions & Answers

When you source a styling sheet or a javascript library, does the web page load everything?
For example, if I source a jQuery library, is the webpage going to load everything off the library and as a result, actually increase the loading time ... Read more (1 answers)
How can I setup a CCTV IP camera and view it as a secure webpage?
I have a standard home router , which NATs private IP's --how can I give the CCTV a static IP and NAT that ?It is a netgear router--tha ... Read more (1 answers)
Can I connect two printers via usb to two different PC's via a USB hub?
Hi FolksThe printers are not network capable (no ether net port) ,I have two PC's in adjoining offices --can I connect both printers to ... Read more (3 answers)
How can i get more followers on twitter?
I only have 24 followers and the people i know dont use twitter. does anyone know how i can get more followers so i dont feel like im talking to mysel ... Read more (4 answers)
Laptop wifi not accepting network key?
Hey we're with sky and have a wireless router. There are two laptops in the house and an xbox 360 which are all wireless. Up until now everything ... Read more (3 answers)