I now have a website which is using drupal. This is the 'main' website on the www domain. I would like to build a small gimmick which is only accessible to my users. This gimmick site is probably not using drupal at all.

Is there a way to duplicate the login procedure for my subdomain so that only users from my main site can use the gimmick site?

thanks in advance

1 Answer 1


Yes,there is no problem using drupal user table, you just need implement you site and connect to data base that Drupal install on it and then just need use user table , only one note remain that the password saved with md5 method in user table.
I thing is not complex, the summery of answer is connect to db use uid(or name) and password field of users table .

as sample code :


$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name="drupaldb"; // Database name
$tbl_name="users"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// username and password sent from form

// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = md5(mysql_real_escape_string($mypassword));

$sql="SELECT * FROM $tbl_name WHERE name='$myusername' and pass='$mypassword'";

// Mysql_num_row is counting table row

// If result matched $myusername and $mypassword, table row must be 1 row

// want to want
echo "congratulation ,you login";

else {
echo "Wrong Username or Password";
  • Would've worked well, but the password row in any drupal is hashed. I think for security reasons.
    – hasdrubal
    Dec 15, 2013 at 15:06
  • yes, it is hashed by md5 method. md5 hashing is very simple in php/
    – Yuseferi
    Dec 15, 2013 at 15:38
  • @user1111652 ,you should md5 hashing method
    – Yuseferi
    Dec 15, 2013 at 16:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.