MyBB Community Forums

Full Version: Automatically register and login users
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I am trying to figure out if it would be possible to automatically register and login users. The forum is to sit inside a site where in order to access the forum, users must be logged in already.

I therefore don't want them to have to register for the forum as well, but rather use their initial username and password to gain access to the forum automatically.

I also need to remove the email address and a few other things on initial login/registration (email related), but I expect this would be made clear if I can just find the elements which deal with registration.

I have had a long look through the community forum here, but can't find anything which has already covered this. Can anyone give me any tips?

cheers,

Derek
You need a bridge from your site to your forum.
You'll need a plugin for that, but I'm not sure there are any already.
I found the easyist way to combine the two is by using MyBB login system and just adding it to your site. http://community.mybboard.net/showthread.php?tid=6190
but you'll have to transfer all users from your website database to the mybb one.
Thanks to both for your tips, but it need it to be seamless. I also need to be able to choose which registration elements are necessary (no email related questions).

If it is not possible without pulling this forum software apart maybe it makes more sense to find a different one or build from scratch. Unfortunate if this is the case - mybb seems quite good.

cheers,

Derek
You're probably going to have this problem with any forum software.

Maybe you know a friend who's good in php that can help you out a little?
Thanks for the friendly tip - I am a php developer, so the onus is on me. My original question was how to figure out enough of the structure of mybb to understand how I could bypass the current login system. Is there, for example, some good documentation on this software, or do I just have to trawl through it until I find what I am looking for?

The issue is not so much skill (I hope not, anyway, otherwise I am in serious trouble Smile but time.

cheers, and thanks for your help.

Derek
The mybb wiki contains lots of information:
http://wiki.mybboard.net/index.php/Main_Page

And here's info about plugin handles and locations:
http://community.mybboard.net/showthread.php?tid=3553

And the user submitted tutorials might also help you:
http://community.mybboard.net/forumdisplay.php?fid=38
If you can modify your website's registration code, you can make it so that whenever a user registers on the site, a copy of the username and password is inserted into mybb_users. To make the password work, just insert the md5 hash of the plain text password in the password field, and leave the salt and login key empty. Most of the other fields can be left by default and set by the user in the User CP, but if you want you can insert default user settings.
this is exactly what i am trying to do is there any info on how to do it?
(2007-06-28, 04:53 PM)DennisTT Wrote: [ -> ]If you can modify your website's registration code, you can make it so that whenever a user registers on the site, a copy of the username and password is inserted into mybb_users. To make the password work, just insert the md5 hash of the plain text password in the password field, and leave the salt and login key empty. Most of the other fields can be left by default and set by the user in the User CP, but if you want you can insert default user settings.

my register code how would i go about doing it?
<?php
include 'config.php';
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html> 

<head>



<meta http-equiv="content-type" content="text/html; charset=UTF-8">

 
<script language="javascript">
function verify()
{
	var filter=/^.+@.+\..{2,3}$/;
if(document.frm.username.value.split(" ").join(" ")== "")
{
alert("You must enter username");
document.frm.username.focus();
document.frm.username.select();
return false;
}
if(document.frm.passwd.value.split(" ").join(" ")== "")
{
alert("You must enter password");
document.frm.passwd.focus();
document.frm.passwd.select();
return false;
}
if(document.frm.emailid.value.split(" ").join(" ")== "")
{
alert("You must enter email");
document.frm.emailid.focus();
document.frm.emailid.select();
return false;
}
else if(filter.test(document.frm.emailid.value)==false)
{
alert("you must enter Invalid email");
document.frm.emailid.focus();
document.frm.emailid.select();
return false;
}
	
else
return true;

}
</script>	
</head>

<body>
<?
if(isset($_POST['username']))
{
 $username=$_POST['username'];
 $passwd=$_POST['passwd'];
 $emailid=$_POST['emailid'];
 $password=md5($passwd);
 /*echo"$username";
 echo"$passwd";
 echo"$emailid";
 */
  $query1=mysql_query("select * from users where username='$username' and password='$password'");

  $cnt=mysql_num_rows($query1);
  //echo"$cnt";
  if($cnt>0)
  {
   header("location:user_reg.php?err=login");
   }
  else
  {
   $query="insert into users(uid,username,password,emailid) VALUES ('','$username','$password','$emailid')";
 //echo"Insert".$query;

 $result=mysql_query($query);
 if($result)
	 {
	 echo"<br><br>";
	 echo"<font color='#cc0000'><em>You have successfully registered..</em></font>";
	 } 
 }
} 	 
else
{  
    echo"<strong><font color='#e00609'>Registration form:-</font></strong><br>";   
	echo "<form name=\"frm\" method=\"post\" action=\"user_reg.php\" onSubmit='return verify()' >";
	echo "<table width='100%' border='0' cellspacing=2' cellpadding='3'>";
	echo"<tr><td width='20%'><strong>Username :-</strong></td>    <td width='80%'><input name=\"username\" type=\"text\" size=\"25\"></td></tr>";
	 
	echo"<tr><td width='20%'><strong>Password :-</strong></td>    <td width='80%'><input name=\"passwd\" type=\"text\" size=\"25\"></td></tr>";
	echo"<tr><td width='20%'><strong>Email Id :-</strong></td>    <td width='80%'><input name=\"emailid\" type=\"text\" size=\"25\"></td></tr>";
   
 	
 	echo"<tr><td width='20%'></td><td width='80%'><input type='submit' name='Submit' value='Submit'></td></tr>";
	if($_GET['err']=="login")
	{
	 echo"<br>";
	 echo"<tr><td width='20%'></td><td width='80%'><font color='#cc0000'><em> This username is already registered.<br>please registered again.</em></font></td></tr>";

	}
	echo"</table><br>"; 
    echo"</form>"; 
    //echo '<input type="submit" name="Submit" value="Submit"></form>';
	
}

// Closing connection
mysql_close($link);
?>
</body>

</html>

anyone?