News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

create an account(smf) with mysql query

Started by samuelggt, May 02, 2015, 11:19:44 AM

Previous topic - Next topic

samuelggt

Hi, as I can register an account with a mysql query, the problem I found is in the part of the password, anyone can help me or guide on how to solve this, thanks.

So I have my query:

INSERT INTO `smf_members` (real_name, passwd, member_name, id_post_group, email_address) VALUES ('Samuel', sha1(Sam), 'Samuel', '4', '[email protected]')

margarett

I edited your block of code to remove your email address ;)

It's not really recommended to directly interact with the database, as SMF has routines prepared to do it. The best way is to create a PHP file, require SSI.php and Sources/Subs-Members.php, then fill the $regOptions array and finally call registerMember($regOptions);

If you still want to go the manual way, you need to:
* insert the record in smf_members as you're doing. Password is sha1(strtolower($username) . $password)
* update smf_settings to increase the total of users
* update smf_settings to update "last member"
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

samuelggt

QuotePassword is sha1(strtolower($username) . $password)
To make it get error:

margarett

Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

samuelggt

Is there a way to change the syntax of php to mysql query?

Kindred

Not really...

As has already been said, smf has some functions that already exist and are hooked and/or available to do exactly whatbyoubarebtrying to do.   Why are you trying to drop users directly in the database?   Because there are things that have to happen when a user is created, other then just the members table
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

samuelggt

It's for a game (SAMP) in which to sign up for the game, also do the SMF sending a mysql query.

JBlaze

<?php
require_once('/path/to/SSI.php');

global 
$sourcedir;

require_once(
$sourcedir '/Subs-Members.php');

$regOptions = array(
    
'real_name' => $username,
    
'passwd' => sha1(strtolower($username) . $password),
    
'member_name' => $username,
    
'id_post_group' => $postgroup,
    
'email_address' => $email
);

registerMember($regOptions);
?>


It's that easy. You can include SSI.php anywhere you need to use it outside of your forum, and you can do damn near anything with it. The $regOptions array keys are the same as the smf_members keys.
Jason Clemons
Former Team Member 2009 - 2012

Kindred

In other words... do it, correctly, in php - with a call to the SMF register function... don't try to bypass or shortcut things by doing it directly in mySQL
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Advertisement: