Advertisement:
2by2host

Author Topic: Help with registration  (Read 5386 times)

Offline Snakeman

  • Newbie
  • *
  • Posts: 6
Help with registration
« on: June 13, 2012, 12:48:28 PM »
I'm making a gamemode for sa-mp online game.It works synchronized with my simple machines forum.If you register ingame,you can use your account in smf too.If you register at site,you can use your account in game too.
Because of this,i need a code for registration.
Example:
Code: [Select]
INSERT INTO smf_members ("Snakeman"...)
Thanks..[/b]

Offline emanuele

  • Developer
  • SMF Super Hero
  • *
  • Posts: 11,909
  • Gender: Male
  • Because Orange is Orange
Re: Help with registration
« Reply #1 on: June 13, 2012, 01:22:36 PM »
Hello Snakeman and welcome to sm.org! :)

You may want to use SMF function registerMember, this is an example taken from ManageRegistrations.php:
Code: [Select]
$regOptions = array(
'interface' => 'admin',
'username' => $_POST['user'],
'email' => $_POST['email'],
'password' => $_POST['password'],
'password_check' => $_POST['password'],
'check_reserved_name' => true,
'check_password_strength' => false,
'check_email_ban' => false,
'send_welcome_email' => isset($_POST['emailPassword']) || empty($_POST['password']),
'require' => isset($_POST['emailActivate']) ? 'activation' : 'nothing',
'memberGroup' => empty($_POST['group']) || !allowedTo('manage_membergroups') ? 0 : (int) $_POST['group'],
);

require_once($sourcedir . '/Subs-Members.php');
$memberID = registerMember($regOptions);

You have to fill the array $regOptions with the few informations required (interface should be guest and not admin in your case I think), and SMF will take care of create the user.

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Offline Snakeman

  • Newbie
  • *
  • Posts: 6
Re: Help with registration
« Reply #2 on: June 13, 2012, 01:39:20 PM »
Hello Snakeman and welcome to sm.org! :)

You may want to use SMF function registerMember, this is an example taken from ManageRegistrations.php:
Code: [Select]
$regOptions = array(
'interface' => 'admin',
'username' => $_POST['user'],
'email' => $_POST['email'],
'password' => $_POST['password'],
'password_check' => $_POST['password'],
'check_reserved_name' => true,
'check_password_strength' => false,
'check_email_ban' => false,
'send_welcome_email' => isset($_POST['emailPassword']) || empty($_POST['password']),
'require' => isset($_POST['emailActivate']) ? 'activation' : 'nothing',
'memberGroup' => empty($_POST['group']) || !allowedTo('manage_membergroups') ? 0 : (int) $_POST['group'],
);

require_once($sourcedir . '/Subs-Members.php');
$memberID = registerMember($regOptions);

You have to fill the array $regOptions with the few informations required (interface should be guest and not admin in your case I think), and SMF will take care of create the user.
My friends tells me that,you must fill all coloumns at smf_members table.I told them that i must only fill required coloumns and smf will take care of the others.They don't believed me :) Thank you very much,that's what i wanted,but i need it as INSERT INTO command.

Offline emanuele

  • Developer
  • SMF Super Hero
  • *
  • Posts: 11,909
  • Gender: Male
  • Because Orange is Orange
Re: Help with registration
« Reply #3 on: June 13, 2012, 04:21:35 PM »
I'd really suggest you to use the function instead of directly insert things, this is way more reliable and it will be compatible with future versions of SMF.
Additionally the members table is not the only one that is populated when a user registers.

If you really want to go with the insert, I think it would be better if you check the registerMember function and see what is mandatory and what is not and how things must be stored (remember the password is encrypted for example).

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Offline Snakeman

  • Newbie
  • *
  • Posts: 6
Re: Help with registration
« Reply #4 on: June 13, 2012, 04:30:09 PM »
I'd really suggest you to use the function instead of directly insert things, this is way more reliable and it will be compatible with future versions of SMF.
Additionally the members table is not the only one that is populated when a user registers.

If you really want to go with the insert, I think it would be better if you check the registerMember function and see what is mandatory and what is not and how things must be stored (remember the password is encrypted for example).
OK,i will try to make this with registerMember function.Thank you.

Offline Snakeman

  • Newbie
  • *
  • Posts: 6
Re: Help with registration
« Reply #5 on: June 18, 2012, 07:31:28 AM »
Well,i did with registerMember,my register php is this:
Code: [Select]
<?php
define
('SMF'1);
$regOptions = array(
'interface' => 'guest',
'username' => $_GET['isim'],
'email' => $_GET['email'],
'password' => $_GET['sifre'],
'password_check' => $_GET['sifre'],
'check_reserved_name' => true,
'check_password_strength' => false,
'check_email_ban' => false,
'send_welcome_email' => isset($_GET['emailPassword']) || empty($_GET['password']),
'require' => isset($_POST['emailActivate']) ? 'activation' 'nothing',
'memberGroup' => empty($_GET['group']) || !allowedTo('manage_membergroups') ? : (int) $_GET['group'],
);

require_once('forum/Sources/Subs-Members.php');
registerMember($regOptions);
?>


But there is an error;
Code: [Select]
Fatal error: Call to undefined function loadLanguage() in C:\inetpub\vhosts\element-samp.net\httpdocs\forum\Sources\Subs-Members.php on line 464

Offline emanuele

  • Developer
  • SMF Super Hero
  • *
  • Posts: 11,909
  • Gender: Male
  • Because Orange is Orange
Re: Help with registration
« Reply #6 on: June 18, 2012, 08:24:51 AM »
Instead of:
Code: [Select]
<?php
define
('SMF'1);
use:
Code: [Select]
<?php
require_once('/paht/to/smf/directory/SSI.php');

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Offline Snakeman

  • Newbie
  • *
  • Posts: 6
Re: Help with registration
« Reply #7 on: June 18, 2012, 02:08:41 PM »
Done,it registers now. Thank you a lot,emanuele.