MyBB Community Forums

Full Version: Custom Register
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am trying to integrate my site to the forums, and one of the big issues I would like to learn about is how to create a simple login page, which checks via the forum database.

For example, I could register on the site, and my account would count for both the site and forum. Similarly, if I was registered in the forums, I should be able to login on the site.

A simple script would be nice. I know how to use some HTML and CSS, so I just need a plain PHP script. I can style it later.

Forum = http://gmqa.64digits.com/forums

** EDIT: Never mind, I found this: http://community.mybboard.net/showthread.php?tid=6190

New Problem, how can I integrate a registration system?
Have you tried replicating the form that MyBB has?
I couldn't find where that form is. I already have the login form by myself. I just need the registration form.
Just logout of your forum, and click "Register" and then click "I agree". You can base your registration form with that HTML.
DennisTT Wrote:Just logout of your forum, and click "Register" and then click "I agree".  You can base your registration form with that HTML.

The following code does work for me. Can be used on any page outside myBB on your own sites. Note: I have tested it only twice, so don't know about longtime issues - haven't tested it with duplicate loginnames aso. Please change the paths and DB-Class to your own.

First, create Captcha-Image-Settings (note: function random_str() can also be included from mybb/in/functions.php)

function random_str($length="8")
{
	$set = array("a","A","b","B","c","C","d","D","e","E","f","F","g","G","h","H","i","I","j","J","k","K","l","L","m","M","n","N","o","O","p","P","q","Q","r","R","s","S","t","T","u","U","v","V","w","W","x","X","y","Y","z","Z","1","2","3","4","5","6","7","8","9");
	$str;
	for($i = 1; $i <= $length; $i++)
	{
		$ch = rand(0, count($set)-1);
		$str .= $set[$ch];
	}
	return $str;
}

$randomstr = random_str(5);
$imagehash = md5($randomstr);
$imagestring = $randomstr;
		
$db->query("insert into mybb_captcha values('$imagehash','$imagestring','".time()."')");

Then, add your form. These fields are required:
<form id="register" action="/forum/member.php" method="post">
    <input type="text"" name="username" value="" />
    <input type="password"" name="password" />
    <input type="password"" name="password2" />
    <input type="text"" name="email" value="" />
    <input type="text"" name="email2" value="" />
    <input type="hidden" name="referrername" value="" />

    <img src="forum/captcha.php?action=regimage&imagehash=<?=$imagehash?>" />
    <input type="text" name="imagestring"  />
    <input type="hidden" name="imagehash" value="<?=$imagehash?>" />
    
    <input type="hidden" name="allownotices" value="yes" />
    <input type="hidden" name="hideemail" value="" />
    <input type="hidden" name="emailnotify" value="" />
    <input type="hidden" name="receivepms" value="yes" />
    <input type="hidden" name="pmpopup" value="yes" />
    <input type="hidden" name="emailpmnotify" value="" />
    <input type="hidden" name="invisible" value="" />
	<input type="hidden" name="timezoneoffset" value="+1" />
	<input type="hidden" name="enabledst" value="" />
	<input type="hidden" name="language" value="" />
	<input type="hidden" name="action" value="do_register" />
	
	<input type="hidden" name="timezoneoffset" value="+1" />
	<input type="hidden" name="timezoneoffset" value="+1" />
		
    <input type="submit" value="submit" />
  

</form>

That's it. Finetuning needs to be done of course ;-)
no font captcha..?
First of all, don't bump other people's threads. Start a new one. And second re upload your Captcha fonts