2

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

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 :

<?php

$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
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];

// 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'";
$result=mysql_query($sql);

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);

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

if($count==1){
// 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 '13 at 15:06
  • yes, it is hashed by md5 method. md5 hashing is very simple in php/ – Yusef Dec 15 '13 at 15:38
  • @user1111652 ,you should md5 hashing method – Yusef Dec 15 '13 at 16:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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