You'll have to forgive me, as I am very new to what I am trying to learn! But there is a starting point for everything...
I'm using PHP and MySQL for a password protected website that will have multiple users... and I think I'm very close to getting it to work. The password will be the same for all users, which they will be given. The problem I'm having is that when I put in a username and password, I get redirected to the Login Failed page. I think it might have something to do with the section of my code below. My table is called "users," and in the SESSION part, I've put the first three parts of the table in there... the user, full_names, and guest_one. I'm not really sure if I did that part correctly either.
Also, I thought I read somewhere that the .md5 part of this code was for passwords that are encrypted. Do I need this if everyone is going to have the same password. This site is not high-security or anything.
One last thing... I've set up my table in MySQL, and I know that I've got that set up correctly... the only problem is, how do I get all of the user, password, name information into that table? Where does it pull that information from. I have a mysql.sql text document, does it come from there?
//Create query
$qry="SELECT * FROM users WHERE user='$user' AND pass='".md5($_POST['password'])."'";
$result=mysql_query($qry);
//Check whether the query was successful or not
if($result) {
if(mysql_num_rows($result) == 1) {
//Login Successful
session_regenerate_id();
$member = mysql_fetch_assoc($result);
$_SESSION['SESS_USER'] = $user['user'];
$_SESSION['SESS_FULL_NAMES'] = $user['full_names'];
$_SESSION['SESS_GUEST_ONE'] = $user['guest_one'];
session_write_close();
header("location: member-index.php");
exit();
}else {
//Login failed
header("location: login-failed.php");
exit();
}
}else {
die("Query failed");
}Let me know if you need more information that this. I'm sorry if these sounds like really dumb questions, but like I said, I'm brand new to this! I appreciate any help.
Thanks!