Hi,
i am trying to make a simple script in php.. right now i can add to database to mySql..
my First code in adding data is here:
Now, my problem is here when im trying to logon is ok but if i write wrong username and password is not giving error but need answer is this ("username and password is invalid"); ..PHP Code:<?
//replace username and password with your mysql name and password
$conn = mysql_connect("localhost","USERNAME","PASSWORD");
//select the database
$db = mysql_select_db("wwwtest_db");
$username = $_POST["username"];
$password = $_POST["password"];
$credits = $_POST["credits"];
//insert the values
$result= MYSQL_QUERY("INSERT INTO users (id, username, password, credits)".
"VALUES ('NULL', '$username', '$password', '$credits')");
echo "Username and password with credits submitted ok.";
?>
the code is here:
PHP Code:<?
$conn = mysql_connect("localhost","USERNAME","PASSWORD");
$db = mysql_select_db("wwwtest_db");
$username = $_POST["username"];
$password = $_POST["password"];
$result = MYSQL_QUERY("SELECT * from users WHERE username='$username'and
password='$password'")
or die ("username and password is invalid");
$worked = mysql_fetch_array($result);
$username = $worked[username];
$password = $worked[password];
$email = $worked[email];
if($worked)
echo "Welcome $user! Your Credit left is $credits";
?>




Reply With Quote