|
Last updated: 09/04/2010
Here's a php
snippet that connects to your vbulletin database and checks a username / password against it. This is useful for having other scripts on your site authenticate users against the same registered user list as vbulletin.
<?
$host = "hostname"; $user = "username"; $pass = "password"; $db = "database";
$conn = mysql_connect($host, $user, $pass); mysql_select_db($db, $conn); $sql = "SELECT userid, usergroupid, membergroupids, infractiongroupids, username, password, salt FROM vb_user WHERE username = '" . htmlspecialchars($username). "'";
$r = mysql_query($sql,$conn); $results = mysql_fetch_array($r, MYSQL_ASSOC);
mysql_free_result($r);
if($results['password'] != '' && $results['password'] == md5(md5($password).$results['salt'])) { // this is a match } else { // this is not a match } ?>
|