MyBB Community Forums

Full Version: Registration Script (Developement)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I tried to make a script registration for my site then can be use at myBB Board but when i try to login into forum myBB was denied or like username & password not in database..just like not accepted by myBB .Can u resolve or gimme a solution ??

this code i put on registration.php :
...
// .. i cut need to show

$name = strip_tags($_POST['name']);
$email = strip_tags($_POST['email']);
$epass = strip_tags($_POST['pwd']);

error_reporting(E_ALL & ~E_NOTICE);

require_once 'forum/inc/class_core.php';
$mybb = new MyBB;

require_once 'forum/inc/config.php';
require_once 'forum/inc/class_timers.php';
require_once 'forum/inc/functions.php';
require_once 'forum/admin/adminfunctions.php';
require_once 'forum/inc/class_xml.php';
require_once 'forum/inc/functions_user.php';
require_once 'forum/inc/class_language.php';

	require_once "forum/inc/db_mysql.php";
	require_once 'forum/inc/settings.php';
	$mybb->settings = &$settings;

	$db = new databaseEngine;
	$db->connect('localhost', 'xxx', 'xxx');
	$db->select_db('forum');
	
	$now = time();
	$salt = random_str();
	$loginkey = generate_loginkey();
	$saltedpw = md5(md5($salt).md5('$epass'));

	$newuser = array(
		'username' => "$name",
		'password' => $saltedpw,
		'salt' => $salt,
		'loginkey' => $loginkey,
		'email' => "$email",
		'usergroup' => 2,
		'regdate' => $now,
		'lastactive' => $now,
		'lastvisit' => $now,
		'website' => '',
		'icq' => '',
		'aim' => '',
		'yahoo' => '',
		'msn' =>'',
		'birthday' => '',
		'signature' => '',
		'allownotices' => 'yes',
		'hideemail' => 'no',
		'emailnotify' => 'no',
		'receivepms' => 'yes',
		'pmpopup' => 'yes',
		'pmnotify' => 'yes',
		'remember' => 'yes',
		'showsigs' => 'yes',
		'showavatars' => 'yes',
		'showquickreply' => 'yes',
		'invisible' => 'no',
		'style' => '0',
		'timezone' => 0,
		'dst' => 'no',
		'threadmode' => '',
		'daysprune' => 0,
		'regip' => "$lastip",
		'language' => '',
		'showcodebuttons' => 1,
		'tpp' => 0,
		'ppp' => 0,
		'referrer' => 0,
		'buddylist' => '',
		'ignorelist' => '',
		'pmfolders' => '',
		'notepad' => ''
	);

	$db->insert_query('mybb_users', $newuser);
	$uid = $db->insert_id();
  print "<br><br><hr>Registration Complete<br>";
  print "You account has active ,thanks for join whit us!<hr>";

In your array the $name and $email shouldn't be in quotes.

example
       'email' => $email,

Usergroup should be in quotes. Also check the database and see if a new user is even created. You can also try to echo the query to see what it's spitting out. Do you get any errors?
everything is ok.all data was inserting into mybb_user database by submit,but still can't login whit their default username & password.A new user created and no error found while query ..but login or even create new thread was not accepted.

this result when login ;

user register or administration whill show a message:

You have successfully been logged in.
You will now be taken back to where you came from.
Redirecting....

a new user:
The password you entered is incorrect. If you have forgotten your password, click here. Otherwise, go back and try again.
You have 2 more login attempts.
Are you sure you are creating the password properly?  Try to do a password recover and if you can reset the password and login works then you know that's the problem.

Here are some lines of code I used in my password reset plugin.

         $password = random_str(10);
         $salt = generate_salt();
         $loginkey = generate_loginkey();
         $saltedpw = md5(md5($salt).md5($password));

and
            $update_array = array(
                'password' => $saltedpw,
                'salt' => $salt,
                'loginkey' => $loginkey,
            );


            $db->update_query(TABLE_PREFIX."users", $update_array, "uid='{$user['uid']}'");

That might help you.
$saltedpw = md5(md5($salt).md5('$epass')); <-- that's your problem mate. You can't use single quotes around a $ variable, normal quotes are fine though. But obviously not needed.
i got like this one,but still not work..
this code new user required to change their password after register;
i choose this method because use like your code is more hard where need activication from myBB script function.I have made own script registration activication.


  $name = $_SESSION['player'];
  $epass = strip_tags($_POST['pass']);

         $salt = generate_salt();
         $loginkey = generate_loginkey();
         $saltedpw = md5(md5($salt).md5($epass));

$query = $db->query("update mybb_users set password='$saltedpw', salt='$salt', loginkey='$loginkey' where username='$player'");


Your code as i know is work but that wasn't i want to use it for update a password
Are you sure $_SESSION['player'] is set? Do you have a session open?

Also we even have a change password feature within MyBB. 0.o
And you can always just change it so that you don't need to activate the account. All these are options. You should read the wiki and look through settings and permissions...
CraKteR Wrote:$saltedpw = md5(md5($salt).md5('$epass')); <-- that's your problem mate. You can't use single quotes around a $ variable, normal quotes are fine though. But obviously not needed.

soory , thats was not works too..

 
  $name = $_SESSION['player'];
  $epass = strip_tags($_POST['pass']);

         $salt = generate_salt();
         $loginkey = generate_loginkey();
         $saltedpw = md5(md5($salt).md5($epass));

$query = $db->query("update mybb_users set password='$saltedpw', salt='$salt', loginkey='$loginkey' where username='$name'");
      

CraKteR Wrote:Are you sure $_SESSION['player'] is set? Do you have a session open?

Also we even have a change password feature within MyBB. 0.o
And you can always just change it so that you don't need to activate the account. All these are options. You should read the wiki and look through settings and permissions...

$_SESSION['player'] i was used in another page and use for another database.
I mean i have create 2 database ,1 is for profile_db and else for forum_myBB
.I only want take a registration records from profile_db to insert into forum_myBB.So their can use forum whitout register from myBB register function,but came from my own registrarion script.
instead of

 $salt = random_str();
    $loginkey = generate_loginkey();
    $saltedpw = md5(md5($salt).md5('$epass'));

try

		$salt = generate_salt();
  	 	$loginkey = generate_loginkey();
	    $saltedpw = salt_password(md5($epass),$salt);
Pages: 1 2