Hey, thanks for the info! Yeah, PHP is a mind in it's own, and I'm loving it. Never had so much fun getting lost and then finding myself again hehe
However, I do seem to have a problem. Will probably seem kinda simple to the rest of ya, but to me, it's mind boggoling...
As I stated, I am using a script with the following code :
Code: Select all
<?
# Login Code Written by Matt Slavin
# Email Me At neophite17@hotmail.com for questions or comments.
if((!$Username) | (!$Password)) {
print ("Please Enter In THe Correct Name");
}
mysql_connect("localhost","User_Name_here","Password_Here");
mysql_select_db("My_Database_Here");
# This part is sort if ya want to. I would suggest it.
# Make your login page have the main value of Password
#Comment Out if you Want too
$Password = md5($Password);
$sql = "select * from My_Table where Password=$Password and Username=$Username";
$result = mysql_query($sql);
$num = mysql_numrows($result);
# If Login Is Okay Do What You Want TO DO to Them
if ($num == "1") {
print ("Logged in okay");
#Or you can send them somwhere nice like hawaii
header("Location: http://localhost/bob/success.htm");
exit;
# or even fetch feild about them or save sessions
session_start();
session_register(Username);
}
# And we must a have a default error message if login fails
if ($num == "0"){
print ("Sorry Bub You Need Some Manners In Password");
}
?>
I have indeed created the databases needed ( in my case, my db is called auth, and table called userinfo, with the field names of username and password ).
Now, I can connect fine with NO PROBLEMS to the databse...
However, it's not pulling the data, comparing, or handling like it should.
In other words, I did a basic Insert INTO table userinfo values ('bob','bob');
it saves the info, and places a line in the table with bob under the username, and bob under the password.
i do a select * from userinfo and it dispays that I have bob and bob under the correct fields. However, when I try and log in with bob and bob with the login, i only get the message Please Enter In THe Correct Name.
which is what happens if one uses the incorrect username/password.
Now, I found out whilie reading my manual that in order to use $num = mysql_numrows($result) successfully, I have to run a php command in order to do this?? I dunno, I'm confused.
I have done NOTHING except install apache, edit the http.conf file, and install mysql. Is there something special I need to do with mysql or php in order to have it correclty read/display database information?
for those of you wondering, i did log in with a mysql username, and changed the password, and then edited that in the above script. thanks for any information you can provide me with!
