Hi Guys:
I am trying to edit the code below. I have set up a members database which is used to allow members to login into my website. However at the moment everyone who registers can login user their username (email address) and password. I want to change the code so that only those with a status of "1" can login while those with a status of "0" will fail.
I have tried several things to manipulate the code but nothing seems to work. I simply don't know what code to write and where to put it.
I'm really not sure where to start so all help would be greatly appreciated! ???
<?php
$host="localhost"; // Host name
$username="username"; // Mysql username
$password="pw"; // Mysql password
$db_name="dbname"; // Database name
$tbl_name="tablename"; // 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 signup form
$myusername=$_POST['myusername'];
$mypassword=$_POST['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");
header("location:./secure/welcome.php");
}
else {
echo "Wrong Username or Password";
}
?>