Author Topic: Custom integration of SMF with another remote database?  (Read 1274 times)

Offline L2Scarlet

  • Semi-Newbie
  • *
  • Posts: 47
Custom integration of SMF with another remote database?
« on: October 31, 2019, 09:01:18 AM »
I want to register my new users from a custom register page or from the default SMF register page (it doesn't matter) and I need the new users to be registered on BOTH databases, my second database is on another web server... I'm thinking to use a query from PHP with INSERT into second database but I don't know where to add this code, in SMF > Sources > register file ?

...and second I want to create a Recover password or something like that.

Any advice, some code examples will be much appreciated. Thanks in advance.

I have this in my custom register page

Code: [Select]
function register() {
signup_button: document.getElementsByName("sbutton")[0].value,
signup_username: document.getElementsByName("susername")[0].value,
signup_email: document.getElementsByName("semail")[0].value,
signup_expansion: document.getElementsByName("sexpansion")[0].value,
signup_password: document.getElementsByName("spassword")[0].value,
signup_password_repeat: document.getElementsByName("spassword_repeat")[0].value
function (data)
<script src="" async defer></script>
function onSubmit(token) {

<form id="vGR" method="POST" accept-charset="utf-8">
<div style="text-align:left;" class="form-group">
<input type="text" class="form-control" name="susername" maxlength="30" pattern="[a-zA-Z0-9\s-]+" autocomplete="off" required />
<div style="padding-top:20px;"></div>
<div style="text-align:left;" class="form-group">
<label>Email Address</label>
<input type="email" class="form-control" name="semail" maxlength="50" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$" autocomplete="off" required />
<div style="padding-top:20px;"></div>
<div style="text-align:left;" class="form-group">
<input type="password" class="form-control" name="spassword" maxlength="20" autocomplete="off" required />
<div style="text-align:left;" class="form-group">
<label>Confirm Password</label>
<input type="password" class="form-control" name="spassword_repeat" maxlength="20" autocomplete="off" required />
<div style="padding-top:20px;"></div>
<div style="text-align:left;" class="form-group">
<select name="sexpansion" class="form-control" required>
<option value="2">WotLK (x5 server)</option>
<div style="padding-top:20px;"></div>
<div id="info"></div>
<div class="form-group">
<input type="button" name="sbutton" style="background:#0277BD;border-radius:2px;min-width:260px;text-align:center;font-size:17px;padding:20px;margin:0 auto;" data-sitekey="xxxxxxxxxxxxxx" class="btn btn-submit-gen g-recaptcha" onclick="register()" value="Register game account" />
<br />

[b]and PHP now[/b]

$Database = new Database("xxxxxxxxxx", "xxxxxx", "xxxxxxxx", "xxxxxxxx");
try {

$username = $Database->conn->escape_string($_POST['susername']);
$email = $Database->conn->escape_string($_POST['semail']);
$expansion = $Database->conn->escape_string($_POST['sexpansion']);
$password = $Database->conn->escape_string($_POST['spassword']);
$password_repeat = $Database->conn->escape_string($_POST['spassword_repeat']);

$hash_password = strtoupper(sha1(strtoupper($username . ':' . $password)));

if ($Database->insert("account", array($username, $email, $hash_password, $expansion), array("username", "email", "sha_pass_hash", "expansion")) === true) {
$Database->success("Your Account has been created successfully!");

This was just a part of my custom code.. how can I integrate it at least with the SMF registration part ONLY?

P.S. If there is any cost for this. PM me and we can talk. Thx.
I just need a simple integration only to register users on both databases from different servers and not a hook or an advanced script.
I don't need design, form or any html code, etc.  ONLY FEW PHP lines where to add the second and custom query and maybe some SMF variables and functions to be changed.

« Last Edit: October 31, 2019, 09:15:40 AM by L2Scarlet »

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 72,618
    • StoryBB/StoryBB on GitHub
Re: Custom integration of SMF with another remote database?
« Reply #1 on: November 14, 2019, 01:38:31 AM »
Why not just reuse SMF’s database and code?

How to use the SMF user system outside of SMF