2009-06-20, 03:18 PM
Hey, I'm trying to set something up on my site using the database from my mybb. I want to set it up so people who have signed up to the message board have to use that username and password to log into this section.
I have it working with another test database i set up, but it doesn't seem to work with the mybb user
This is what i've got so far:
does mybb md5 the password? does it do anything to the usernames?
I have it working with another test database i set up, but it doesn't seem to work with the mybb user
This is what i've got so far:
<?PHP
//check that the user is calling the page from the login form and not accessing it directly
//and redirect back to the login form if necessary
if (!isset($username) || !isset($password)) {
header( "Location: http://www.site.com/login.html" );
}
//check that the form fields are not empty, and redirect back to the login page if they are
elseif (empty($username) || empty($password)) {
header( "Location: http://www.site.com/login.html" );
}
else{
//convert the field values to simple variables
//add slashes to the username and md5() the password
$user = $_POST['username'];
$pass = md5($_POST['password']);
//set the database connection variables
$dbHost = "my host";
$dbUser = "my username";
$dbPass = "my password";
$dbDatabase = "database name";
//connet to the database
$db = mysql_connect("$dbHost", "$dbUser", "$dbPass") or die ("Error connecting to database.");
mysql_select_db("$dbDatabase", $db) or die ("Couldn't select the database.");
$result=mysql_query("select * from swopono_users where username='$user' && password='$pass'", $db);
//check that at least one row was returned
$rowCheck = mysql_num_rows($result);
if($rowCheck > 0){
while($row = mysql_fetch_array($result)){
//start the session and register a variable
session_start();
session_register('username');
//we will redirect the user to another page where we will make sure they're logged in
header( "Location: www.site.com" );
}
}
else {
//if nothing is returned by the query, unsuccessful login code goes here...
echo 'Incorrect login name or password. Please try again.';
}
}
?>
does mybb md5 the password? does it do anything to the usernames?