Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

{Release} Register account + Integration with Web Shop

Joined
Feb 16, 2014
Messages
652
Reaction score
242
Hello.
First of all this is just a test and i have no clue how this will work on your Server.

Ok lets start from:
A) We need one extra dbo in our database; GlobalDB_Create

Here is our Query to make this dbo
Code:
USE [GlobalDB_Create]
GO

/****** Object:  Table [dbo].[GlobalAccount]  Create By ShadoW Script Date: 2/16/2024 10:03:09 AM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[GlobalAccount](
    [USN] [bigint] NOT NULL,
    [accountName] [varchar](50) NOT NULL,
    [accountPassword] [varchar](100) NOT NULL,
    [Email] [varchar](100) NOT NULL,
    [RegistrationDate] [datetime] NOT NULL
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[GlobalAccount] ADD  DEFAULT (getdate()) FOR [RegistrationDate]
GO

B) Next step is make fill one row in that dbo with USN accountName accountPassword email and registerdate
after create this dbo you need a php for register

C) copy paste in Notepad++ and save as php then copy and paste on your web server side
Code:
<?php
// Połączenie z bazą danych
// Author: Shadow
// Created for RageZone Community
$serverName = "server_name"; //Your server name
$connectionOptions = array(
    "Database" => "GlobalDB_Create",
    "Uid" => "SQL DATABASE_USER", // change this to your Admin login for SQL
    "PWD" => "Password" // Set the password
);
$conn = sqlsrv_connect($serverName, $connectionOptions);
if ($conn === false) {
    die(print_r(sqlsrv_errors(), true));
}

// Obsługa przesłanych danych z formularza
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $accountName = $_POST['accountName'];
    $accountPassword = $_POST['accountPassword'];
    $email = $_POST['email'];

    // Sprawdzenie, czy konto o podanej nazwie już istnieje
    $sql_check = "SELECT * FROM GlobalAccount WHERE accountName = ?";
    $params = array($accountName);
    $stmt = sqlsrv_query($conn, $sql_check, $params);
   
    if ($stmt === false) {
        die(print_r(sqlsrv_errors(), true));
    }

    if (sqlsrv_has_rows($stmt)) {
        echo "Konto o podanej nazwie już istnieje lub wystąpił problem podczas rejestracji. Prosimy spróbować ponownie później.";
    } else {
        // Pobranie nowej wartości USN - na przykład, możesz pobrać maksymalny obecny USN i dodać 1
        $sql_max_usn = "SELECT MAX(USN) AS MaxUSN FROM GlobalAccount";
        $stmt_max_usn = sqlsrv_query($conn, $sql_max_usn);
        $row_max_usn = sqlsrv_fetch_array($stmt_max_usn, SQLSRV_FETCH_ASSOC);
        $max_usn = $row_max_usn['MaxUSN'];
        $new_usn = $max_usn + 1;

        // Dodanie danych do tabeli GlobalAccount
        $sql_insert_global = "INSERT INTO GlobalAccount (USN, accountName, accountPassword, Email) VALUES (?, ?, ?, ?)";
        $params_insert_global = array($new_usn, $accountName, $accountPassword, $email);
        $stmt_insert_global = sqlsrv_query($conn, $sql_insert_global, $params_insert_global);

        if ($stmt_insert_global === false) {
            die(print_r(sqlsrv_errors(), true));
        } else {
            echo "The account has been successfully registered.<br>and<br>";
           
            // Dodatkowe działania po udanym wstawieniu danych do tabeli GlobalAccount
            // Na przykład, dodanie danych do tabeli Web_Account, LocalAccount i Account

            // Dodanie danych do tabeli Web_Account
            $sql_insert_web = "INSERT INTO Web_Account (USN, accountName, accountPassword) VALUES (?, ?, ?)";
            $params_insert_web = array($new_usn, $accountName, $accountPassword);
            $stmt_insert_web = sqlsrv_query($conn, $sql_insert_web, $params_insert_web);

            if ($stmt_insert_web === false) {
                die(print_r(sqlsrv_errors(), true));
            } else {
                echo "your account has been successfully integrated with the Online Store.";
            }

            // Dodanie danych do tabeli LocalAccount
            $sql_insert_local = "INSERT INTO LocalAccount (USN, accountName, REGDATE) VALUES (?, ?, GETDATE())";
            $params_insert_local = array($new_usn, $accountName);
            $stmt_insert_local = sqlsrv_query($conn, $sql_insert_local, $params_insert_local);

            if ($stmt_insert_local === false) {
                die(print_r(sqlsrv_errors(), true));
            } else {
                echo " ";
            }

            // Dodanie danych do tabeli Account
            $sql_insert_account = "INSERT INTO Account (USN, GMLevel, REGDATE, lastAccessServerId) VALUES (?, 0, GETDATE(), 101)";
            $params_insert_account = array($new_usn);
            $stmt_insert_account = sqlsrv_query($conn, $sql_insert_account, $params_insert_account);

            if ($stmt_insert_account === false) {
                die(print_r(sqlsrv_errors(), true));
            } else {
                echo " ";
            }
        }
    }
}
?>

<!-- Formularz rejestracji -->
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
    User Name:<br><input type="text" name="accountName" required><br>
    Password:<br> <input type="password" name="accountPassword" required><br>
    E@mail:<br> <input type="email" name="email" required><br><br>
    <input type="submit" value="Zarejestruj">
</form>

<?php
// Zamknięcie połączenia z bazą danych
sqlsrv_close($conn);
?>
Sorry that the register form have Polish language (you can easy translate with google translator)

That's all you can upgrade this php but remember about owner of this php

Also I did not implement many things, so fill free to implement them

You are still able to make account for game with Start.bat but this account will be not integrate with Web Shop

And I will be not surprise when you will start selling this as own (this only for leachers)

I see lots of Like and lots of just take. That's why many of us won't share any thing.
 
Last edited:
Custom Title Activated
Loyal Member
Joined
Aug 23, 2010
Messages
1,544
Reaction score
423
thanks for share, it's English script

<?php
// Database Connection
// Author: Shadow
// Created for RageZone Community
$serverName = "server_name"; //Your server name
$connectionOptions = array(
"Database" => "GlobalDB_Create",
"Uid" => "SQL DATABASE_USER", // change this to your Admin login for SQL
"PWD" => "Password" // Set the password
);
$conn = sqlsrv_connect($serverName, $connectionOptions);
if ($conn === false) {
die(print_r(sqlsrv_errors(), true));
}

// Handling submitted data from the form
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$accountName = $_POST['accountName'];
$accountPassword = $_POST['accountPassword'];
$email = $_POST['email'];

// Checking if an account with the given name already exists
$sql_check = "SELECT * FROM GlobalAccount WHERE accountName = ?";
$params = array($accountName);
$stmt = sqlsrv_query($conn, $sql_check, $params);

if ($stmt === false) {
die(print_r(sqlsrv_errors(), true));
}

if (sqlsrv_has_rows($stmt)) {
echo "An account with the provided name already exists, or there was an issue during registration. Please try again later.";
} else {
// Getting a new USN value - for example, you can retrieve the maximum current USN and add 1
$sql_max_usn = "SELECT MAX(USN) AS MaxUSN FROM GlobalAccount";
$stmt_max_usn = sqlsrv_query($conn, $sql_max_usn);
$row_max_usn = sqlsrv_fetch_array($stmt_max_usn, SQLSRV_FETCH_ASSOC);
$max_usn = $row_max_usn['MaxUSN'];
$new_usn = $max_usn + 1;

// Adding data to the GlobalAccount table
$sql_insert_global = "INSERT INTO GlobalAccount (USN, accountName, accountPassword, Email) VALUES (?, ?, ?, ?)";
$params_insert_global = array($new_usn, $accountName, $accountPassword, $email);
$stmt_insert_global = sqlsrv_query($conn, $sql_insert_global, $params_insert_global);

if ($stmt_insert_global === false) {
die(print_r(sqlsrv_errors(), true));
} else {
echo "The account has been successfully registered.<br>and<br>";

// Additional actions after successfully inserting data into the GlobalAccount table
// For example, adding data to the Web_Account, LocalAccount, and Account tables

// Adding data to the Web_Account table
$sql_insert_web = "INSERT INTO Web_Account (USN, accountName, accountPassword) VALUES (?, ?, ?)";
$params_insert_web = array($new_usn, $accountName, $accountPassword);
$stmt_insert_web = sqlsrv_query($conn, $sql_insert_web, $params_insert_web);

if ($stmt_insert_web === false) {
die(print_r(sqlsrv_errors(), true));
} else {
echo "your account has been successfully integrated with the Online Store.";
}

// Adding data to the LocalAccount table
$sql_insert_local = "INSERT INTO LocalAccount (USN, accountName, REGDATE) VALUES (?, ?, GETDATE())";
$params_insert_local = array($new_usn, $accountName);
$stmt_insert_local = sqlsrv_query($conn, $sql_insert_local, $params_insert_local);

if ($stmt_insert_local === false) {
die(print_r(sqlsrv_errors(), true));
} else {
echo " ";
}

// Adding data to the Account table
$sql_insert_account = "INSERT INTO Account (USN, GMLevel, REGDATE, lastAccessServerId) VALUES (?, 0, GETDATE(), 101)";
$params_insert_account = array($new_usn);
$stmt_insert_account = sqlsrv_query($conn, $sql_insert_account, $params_insert_account);

if ($stmt_insert_account === false) {
die(print_r(sqlsrv_errors(), true));
} else {
echo " ";
}
}
}
}
?>

<!-- Registration Form -->
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
User Name:<br><input type="text" name="accountName" required><br>
Password:<br> <input type="password" name="accountPassword" required><br>
E-mail:<br> <input type="email" name="email" required><br><br>
<input type="submit" value="Register">
</form>

<?php
// Closing the database connection
sqlsrv_close($conn);
?>
 
Back
Top