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!

How do i create a registration page?

Newbie Spellweaver
Joined
Jan 25, 2019
Messages
36
Reaction score
3
Hey guys I have a little problem ^^
Do somebody know how to make a registration page for a RoM Server?

How can i connect the sql account registration command with a Website (or somewhere else)?


SQL command to create a account
INSERT INTO [ROM_Account].[dbo].[PlayerAccount]
([Account_ID],[Password],[IsMd5Password],[IsAutoConvertMd5])
VALUES
('accountname','password',0,1)

GO
 
Last edited:
Newbie Spellweaver
Joined
Dec 5, 2018
Messages
59
Reaction score
6
best way would be to create a php script with 2 boxes, the database info, and a create user button. its really simple
 
Upvote 0
Newbie Spellweaver
Joined
Jan 25, 2019
Messages
36
Reaction score
3
best way would be to create a php script with 2 boxes, the database info, and a create user button. its really simple

Okeii but i have no idea how to do that :/ can someone do a little tutorial for this problem?
 
Upvote 0
Newbie Spellweaver
Joined
Dec 5, 2018
Messages
59
Reaction score
6
im working on the code. i believe its done but am going to setup a test website in a closed environment on backup server to test if it works.

You will need to setup a website either locally on your server where you can access it (do NOT enable the internet to access it)

I might make a tutorial, but just in case I dont, start reading and learning. You will need to install xampp without mariadb, and enable php for windows mssql server. once that is done, come back here and I should have some code for you :)
 
Upvote 0
Newbie Spellweaver
Joined
Jan 25, 2019
Messages
36
Reaction score
3
im working on the code. i believe its done but am going to setup a test website in a closed environment on backup server to test if it works.

You will need to setup a website either locally on your server where you can access it (do NOT enable the internet to access it)

I might make a tutorial, but just in case I dont, start reading and learning. You will need to install xampp without mariadb, and enable php for windows mssql server. once that is done, come back here and I should have some code for you :)

Ok i think it works^^ can i have some codes? :D
 
Upvote 0
Newbie Spellweaver
Joined
Jan 25, 2019
Messages
36
Reaction score
3
I tried it a little bit but it dont work :( does anyone have any tips?

HTML CODE: Work!

<!DOCTYPE HTML>
<html>
<link rel="stylesheet" type="text/css" href="css/style.css">
<head>
<title>Example</title>
</head>
<body id="body-style">
<div id="Register">
<fieldset style="width:30%"><legend>Account Creation</legend>
<form method="POST" action="database-connect.php">
<table border="0">
<tr>
<td>Accoutname</td><td> <input type="text" name="username"></td>
</tr>
<tr>
<td>Password</td><td> <input type="password" name="pass"></td>
</tr>
<tr>
<td><input id="button" type="submit" name="submit" value="Register"></td>
</tr>
</table>
</form>
</fieldset>
</div>
</html>


CSS CODE: Work!


/*CSS for REGISTER.HTML*/
#body-style{
background-color:#00bddd;
/*background-image:url('bg.png');*/
}
#Register{
background-image:url('default.png');
background-size:500px 500px;
background-repeat:no-repeat;
background-attachment:fixed;
background-position:center;
margin-top:150px;
margin-bottom:150px;
margin-right:150px;
margin-left:450px;
padding:9px 35px;
}
#button{
border-radius:5px;
width:100px;
height:40px;
background:#ffffff
/*background-image:url('bg.png');*/
font-weight:bold;
font-size:20px;
}
PHP CODE try nr.1: Do not Work!

PHP:
<?php

$serverName = "DESKTOP-4TAN2UH\SQLEXPRESS";
$connectionInfo = array( "Database"=>"ROM_Account" ),
         "UID"=>"romuser",
         "PWD" => "Password");
   
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn === false ) {
     die( print_r( sqlsrv_errors(), true));
}
if(isset($_GET['action']))
{
      if($_GET['action'] == 'add')
      {
            /*Insert data.*/
            $insertSql =  "INSERT INTO [ROM_Account].[dbo].[PlayerAccount]
        ([Account_ID],[Password],[IsMd5Password],[IsAutoConvertMd5])
       VALUES
        ('accountname','password',0,1)
       GO";
       
            $params = array(&$_POST['username'], 
                            &$_POST['pass']);
       
            $stmt = sqlsrv_query($conn, $insertSql, $params);
      }
}
?>




PHP CODE try nr. 2: Do not Work!


PHP:
<?php

$serverName = "DESKTOP-4TAN2UH\SQLEXPRESS";
$connectionInfo = array( "Database"=>"ROM_Account", "UID"=>"romuser", "PWD"=>"Password" );
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn === false ) {
     die( print_r( sqlsrv_errors(), true));
}
if(isset($_GET['action']))
{
      if($_GET['action'] == 'add')
      {
            /*Insert data.*/
            $insertSql = "INSERT INTO Playeraccount (Accountname, Password) 
                          VALUES (?,?)";
     $params = array(&$_POST['Accountname'], 
         &$_POST['Password']);
            $stmt = sqlsrv_query($conn, $insertSql, $params);
            if($stmt === false)
            {
                  /*Handle the case of a duplicte Accountname.*/
                  $errors = sqlsrv_errors();
                  if($errors[0]['code'] == 2601)
                  {
                        echo "The Accountname you entered has already been used.</br>";
                  }
                  /*Die if other errors occurred.*/
                  else
                  {
                        die(print_r($errors, true));
                  }
            }
            else
            {
                  echo "Registration complete.</br>";
            }
      }
}
?>
 
Last edited:
Upvote 0
Newbie Spellweaver
Joined
Mar 22, 2017
Messages
84
Reaction score
7
Did you test if your Scirpt can connect at all?
In any case, you way to connect via the Microsoft SQL driver is right.
Did you install this Microsoft driver?
Here is the link to the driver from Microsoft:


Do you get any error messages?

I had the problem that you really had to specify each column. It's also easier if you enter certain default values in the SQL Database, which are automatically fills in default values. That makes it easyer to script.
 
Upvote 0
Newbie Spellweaver
Joined
Jan 25, 2019
Messages
36
Reaction score
3
Hello :)

i think i will try it again, but i need help :/

do someone have a litte tutorial or script for me to make it easier?^^
 
Upvote 0
Initiate Mage
Joined
May 14, 2020
Messages
1
Reaction score
0
Here is a working one for PHP 7.x.x with ODBC Connect. don't forget to activate the Extension like in XAMPP in the PHP.ini. Enjoy to advance this script.

Code:
<?php

$connection_string = 'DRIVER={SQL Server};SERVER=localhost;DATABASE=ROM_Account';

$user = 'romuser';
$pass = 'romuser';
$conn = odbc_connect( $connection_string, $user, $pass );

if(isset($_POST['username']))
{    $username = $_POST['username'];
}

if(isset($_POST['username']))
{    $passwd = md5($_POST['password']);
}    

/*Insert data.*/

$insertSql = "INSERT INTO [ROM_Account].[dbo].[PlayerAccount]        ([Account_ID],[Password],[IsMd5Password],[IsAutoConvertMd5]) 
VALUES        ('".$username."','".$passwd."','True','True')";

$stmt = odbc_do($conn, $insertSql);

 if($stmt === false) {        echo "The Accountname you entered has already been used.</br>";    } else {
    echo "Registration complete.</br>";
}
?>


Code:
<!DOCTYPE HTML>
<html>
<link rel="stylesheet" type="text/css" href="css/style.css">
<head>
<title>Example</title>
</head><body id="body-style">
<div id="Register">
<fieldset style="width:30%">


<legend>Account Creation</legend>

<form method="POST" action="register.php">
<table border="0">
<tr><td>Accoutname</td><td>
<input type="text" name="username" required></td>
</tr>

<tr><td><label for="pass">Password (8 characters minimum):</label></td><td>
<input type="password" name="password" id="pass" minlength="12" required></td></tr>

<tr><td><input id="button" type="submit" name="submit" value="Register"></td></tr></table>
</form>
</fieldset>
</div>
</html>

Code:
/*CSS for REGISTER.HTML*/
#body-style{background-color:#00bddd;
/*background-image:url('bg.png');*/
}

#Register{background-image:url('default.png');
background-size:500px 500px;
background-repeat:no-repeat;
background-attachment:fixed;
background-position:center;
margin-top:150px;
margin-bottom:150px;
margin-right:150px;
margin-left:450px;
padding:9px 35px;
}

#button{border-radius:5px;width:100px;
height:40px;background:#ffffff
/*background-image:url('bg.png');*/
font-weight:bold;font-size:20px;
}
 
Upvote 0
Newbie Spellweaver
Joined
Jan 25, 2019
Messages
36
Reaction score
3
I got this error messages

__________________________________________________________________________

Notice: Undefined variable: username in C:\xampp\htdocs\index.php on line 20

Notice: Undefined variable: passwd in C:\xampp\htdocs\index.php on line 20

Warning: odbc_do(): SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]Violation of PRIMARY KEY constraint 'PK_PlayerAccount'. Cannot insert duplicate key in object 'dbo.PlayerAccount'. The duplicate key value is ()., SQL state 23000 in SQLExecDirect in C:\xampp\htdocs\index.php on line 22

__________________________________________________________________

Line 20:
VALUES ('".$username."','".$passwd."','True','True')";

Line 22: $stmt = odbc_do($conn, $insertSql);
 
Upvote 0
Back
Top