DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Check IPB User Credientials With PHP

12.26.2009
| 11831 views |
  • submit to reddit
        I was recently writing a script that needed to interact log users in only if they had registered on an IPB 3 forum, and I couldn't find any tips on how to go about it. You may have to edit the table in the query if you have a table prefix.

function userLoginIpb($user, $password) {
	$query = mysql_query("SELECT `members_pass_salt`, `members_pass_hash`
			      FROM `members`
			      WHERE `name` = '$user'");
	$results = mysql_fetch_assoc($query);
	$password = md5(md5($results['members_pass_salt']).md5($password));
		if($password == $results['members_pass_hash']) {
			return true;
			}
			else {
				return false;
				}
}

Usage:
if(userLoginIpb($username, $password)) {
	echo 'logged in';
	}