Hey, well the n00b area is the right place for me heh 😉
I was just having some fun in making my own DB connection to MySql with an user authentication and I think I am kind of getting the idea of how to do this but there seems to be something wrong in my syntax and was wondering if some of you could look at it and tell me what I am doing wrong or even the stuff I am doing right if there is a better way to do it.
<?php require_once('./connections/gateway.php'); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>User Login</title>
</head>
<body>
<?php function login_form(){
?>
<form action="index.php" method="POST">
<h3>System Login</h3>
User Name: <input type="text" name="user_name"><br>
Password : <input type="password" name="password"><br>
<input type="submit" name="submit" value="Login"><br>
</form>
<?php
}
if (!$gateway = mysql_connect($hostname_gateway, $username_gateway, $password_gateway)){
echo ("Error connecting to the database");
}else{
$sql = "SELECT * FROM users WHERE username";
$result = mysql_query($sql);
$row_count = mysql_num_rows($result);
}
if($row_count == 0){
echo "<h3>Unkown username</h3>";
login_form();
}
else $row = mysql_fetch_array($result);
if($password != $row["password"]){
echo "<h3>Incorrect password</h3>";
login_form();
}
?>
</body>
</html>
The error I am currently getting now is:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/u3/mrlogo_main/html/test/index.php on line 31
Thanks for any help, I appreciate it.