Register for your free account! | Forgot your password?

You last visited: Today at 23:46

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Registration.php

Discussion on Registration.php within the Dekaron Private Server forum part of the Dekaron category.

Reply
 
Old   #1
 
tiaguim's Avatar
 
elite*gold: 0
Join Date: Apr 2010
Posts: 42
Received Thanks: 1
Question Registration.php

After countless hours of searching and searching and searching, i came up with this scrip to try to make a php5.6 -> SQL server 2000 connection, it actualy works doesn't show any error but...Doens't send data to the actual database

PHP Code:
<?php
$awnser 
"nuncavida";
$password2 "12345678";
$question "Ratos";
$mail "exemplohotmail";
$accountN "09101410275852";
$database "account";
$user "sa";
$password"1234";
$server "localhost";
$conn odbc_connect("Driver={SQL Server Native Client 10.0};Server=$server;Database=$database;"$user$password);
if(
$conn){
      die(
print_r(sqlsrv_errors(), true));
}


$db_selected mysql_select_db($database$conn);

if (!
$db_selected) {
    die(
'Can\'t use ' .$database': ' .mysql_error());
}

$value $_POST['input1'];

$dk_time=strftime("%y%m%d%H%M%S");
list(
$usec1$sec1) = explode(" ",microtime());
$dk_user_no=$dk_time.substr($usec1,2,2);


mssql_query("Insert Into [TBL_USER] Values ('09101410275532', 'tiaguim32', '12345', 'wefew', 'wefewefw', 'wefeww', '25.66.7.153')");


mysql_close();
?>
Do you guys know any way of making this work? It's making me crazy! Cause the connection works, then? Why it doens't transfer the data to the database colums?

Thanks
tiaguim is offline  
Old 05/28/2018, 00:51   #2
 
ZKDev's Avatar
 
elite*gold: 0
Join Date: Nov 2017
Posts: 552
Received Thanks: 218
@

PHP Code:
INSERT INTO [TBL_USER] (column_1column_2column_3column_4column_5column_6column_7VALUES (
'09101410275532',
'tiaguim32',
'12345',
'wefew',
'wefewefw',
'wefeww',
'25.66.7.153'
); 
You cannot simply insert the values you gotta declare every single column at first.
Even tho Im not sure if your tablename may include '[' or ']' better remove 'em.
ZKDev is offline  
Old 05/28/2018, 00:58   #3
 
tiaguim's Avatar
 
elite*gold: 0
Join Date: Apr 2010
Posts: 42
Received Thanks: 1
Ohhh, also already tryed! Didn't work...

PHP Code:
<?php
$awnser 
"nuncavida";
$password2 "12345678";
$question "Ratos";
$mail "exemplohotmail";
$accountN "09101410275852";
$database "account";
$user "sa";
$password"1234";
$server "localhost";
$conn odbc_connect("Driver={SQL Server Native Client 10.0};Server=$server;Database=$database;"$user$password);

if(
$conn){
      die(
print_r(sqlsrv_errors(), true));
}


$db_selected mysql_select_db($database$conn);

if (!
$db_selected) {
    die(
'Can\'t use ' .$database': ' .mysql_error());
}

$value $_POST['input1'];

$dk_time=strftime("%y%m%d%H%M%S");
list(
$usec1$sec1) = explode(" ",microtime());
$dk_user_no=$dk_time.substr($usec1,2,2);


mssql_query("Insert Into TBL_USER(user_no,user_id,user_pwd,user_mail,user_answer,user_question,IP)  Values ('09101410275532', 'tiaguim32', '12345', 'wefew', 'wefewefw', 'wefeww', '25.66.7.153')");


mysql_close();
?>
It gives a blank page, it means it worked, but when you go to the tbl_user, you don't see the stuff you entered


I know the script is sucky sucky as shit, but it's only for the purpose of making it work xD
tiaguim is offline  
Old 05/28/2018, 01:07   #4


 
iMostLiked's Avatar
 
elite*gold: 1337
Join Date: Apr 2013
Posts: 6,487
Received Thanks: 3,190
Use class.

Example:

PHP Code:
include('MysqliDb.php');
$db = new MysqliDb ('host''username''password''database');

$db->insert('TBL_USER', array(
    
'user_no' => '09101410275532',
    
'...' => '...'
)); 
It's pretty easy, clean and secure since it uses prepared statements.
iMostLiked is offline  
Thanks
1 User
Old 05/28/2018, 01:14   #5
 
tiaguim's Avatar
 
elite*gold: 0
Join Date: Apr 2010
Posts: 42
Received Thanks: 1
Quote:
Originally Posted by iMostLiked View Post
Use class.

Example:

PHP Code:
include('MysqliDb.php');
$db = new MysqliDb ('host''username''password''database');

$db->insert('TBL_USER', array(
    
'user_no' => '09101410275532',
    
'...' => '...'
)); 
It's pretty easy, clean and secure since it uses prepared statements.
Hello! Where do i put the "MysqliDb.php" file? So i can used it in the script?
tiaguim is offline  
Old 05/28/2018, 01:17   #6


 
iMostLiked's Avatar
 
elite*gold: 1337
Join Date: Apr 2013
Posts: 6,487
Received Thanks: 3,190
Quote:
Originally Posted by tiaguim View Post
Hello! Where do i put the "MysqliDb.php" file? So i can used it in the script?
Put it next to your script in the same directory.
iMostLiked is offline  
Old 05/28/2018, 01:23   #7
 
tiaguim's Avatar
 
elite*gold: 0
Join Date: Apr 2010
Posts: 42
Received Thanks: 1
CODE

PHP Code:
<?php
include('MysqliDb.php');
$db = new MysqliDb ('localhost''root''''account');

$db->insert('TBL_USER', array(
    
'user_no' => '09101410275532',
    
'user_id' => 'tiaguim32',
    
'user_pwd' => '1234567',
    
'user_mail' => 'defdewfrwef',
    
'user_answer' => 'fdwefrfwefrwe',
    
'user_question' => 'efdwefewfewf',
    
'IP' => '1523615'
)); 
?>
Result:
Warning: mysqli::mysqli(): (HY000/1049): Unknown database 'account' in C:\xampp\htdocs\MysqliDb.php on line 295

Fatal error: Uncaught exception 'Exception' with message 'Connect Error 1049: Unknown database 'account'' in C:\xampp\htdocs\MysqliDb.php:298 Stack trace: #0 C:\xampp\htdocs\MysqliDb.php(377): MysqliDb->connect('default') #1 C:\xampp\htdocs\MysqliDb.php(1908): MysqliDb->mysqli() #2 C:\xampp\htdocs\MysqliDb.php(1519): MysqliDb->_prepareQuery() #3 C:\xampp\htdocs\MysqliDb.php(1459): MysqliDb->_buildQuery(NULL, Array) #4 C:\xampp\htdocs\MysqliDb.php(765): MysqliDb->_buildInsert('TBL_USER', Array, 'INSERT') #5 C:\xampp\htdocs\Processo2.php(13): MysqliDb->insert('TBL_USER', Array) #6 {main} thrown in C:\xampp\htdocs\MysqliDb.php on line 298

Hmmm, has my knowledge reach, this is going to the datebases os "XAMPP" and not to the databases of SQL server, so thats why it doens't recognize the "account" database, cause it doesn't exist in the "Myphpadmin" stuff xD

Correct me if im wrong



If in the "account" stuff i put one of the myphpadmin default datebases, i get this


Fatal error: Uncaught exception 'Exception' with message 'Table 'test.tbl_user' doesn't exist query: INSERT INTO TBL_USER (`user_no`, `user_id`, `user_pwd`, `user_mail`, `user_answer`, `user_question`, `IP`) VALUES (?, ?, ?, ?, ?, ?, ?)' in C:\xampp\htdocs\MysqliDb.php:1926 Stack trace: #0 C:\xampp\htdocs\MysqliDb.php(1519): MysqliDb->_prepareQuery() #1 C:\xampp\htdocs\MysqliDb.php(1459): MysqliDb->_buildQuery(NULL, Array) #2 C:\xampp\htdocs\MysqliDb.php(765): MysqliDb->_buildInsert('TBL_USER', Array, 'INSERT') #3 C:\xampp\htdocs\Processo2.php(13): MysqliDb->insert('TBL_USER', Array) #4 {main} thrown in C:\xampp\htdocs\MysqliDb.php on line 1926
tiaguim is offline  
Old 05/28/2018, 01:28   #8


 
iMostLiked's Avatar
 
elite*gold: 1337
Join Date: Apr 2013
Posts: 6,487
Received Thanks: 3,190
Quote:
Originally Posted by tiaguim View Post
CODE

PHP Code:
<?php
include('MysqliDb.php');
$db = new MysqliDb ('localhost''root''''account');

$db->insert('TBL_USER', array(
    
'user_no' => '09101410275532',
    
'user_id' => 'tiaguim32',
    
'user_pwd' => '1234567',
    
'user_mail' => 'defdewfrwef',
    
'user_answer' => 'fdwefrfwefrwe',
    
'user_question' => 'efdwefewfewf',
    
'IP' => '1523615'
)); 
?>
Result:
Warning: mysqli::mysqli(): (HY000/1049): Unknown database 'account' in C:\xampp\htdocs\MysqliDb.php on line 295

Fatal error: Uncaught exception 'Exception' with message 'Connect Error 1049: Unknown database 'account'' in C:\xampp\htdocs\MysqliDb.php:298 Stack trace: #0 C:\xampp\htdocs\MysqliDb.php(377): MysqliDb->connect('default') #1 C:\xampp\htdocs\MysqliDb.php(1908): MysqliDb->mysqli() #2 C:\xampp\htdocs\MysqliDb.php(1519): MysqliDb->_prepareQuery() #3 C:\xampp\htdocs\MysqliDb.php(1459): MysqliDb->_buildQuery(NULL, Array) #4 C:\xampp\htdocs\MysqliDb.php(765): MysqliDb->_buildInsert('TBL_USER', Array, 'INSERT') #5 C:\xampp\htdocs\Processo2.php(13): MysqliDb->insert('TBL_USER', Array) #6 {main} thrown in C:\xampp\htdocs\MysqliDb.php on line 298

Hmmm, has my knowledge reach, this is going to the datebases os "XAMPP" and not to the databases of SQL server, so thats why it doens't recognize the "account" database, cause it doesn't exist in the "Myphpadmin" stuff xD

Correct me if im wrong
You didn't even use the credentials you used above for user and password.
It should work if everything is filled in properly, since it's nothing else you did above, only in a cleaner and easier way.
iMostLiked is offline  
Old 05/28/2018, 01:31   #9
 
tiaguim's Avatar
 
elite*gold: 0
Join Date: Apr 2010
Posts: 42
Received Thanks: 1
Quote:
Originally Posted by iMostLiked View Post
You didn't even use the credentials you used above for user and password.
It should work if everything is filled in properly, since it's nothing else you did above, only in a cleaner and easier way.
I had to change the credentials because they don't exist in myphpadmin...if i want to use those credentials i've to create a new user, and them it will give the same error saying that the table doesn't exist xD

PHP Code:
<?php
include('MysqliDb.php');
$db = new MysqliDb ('localhost''sa''1234''account');

$db->insert('TBL_USER', array(
    
'user_no' => '09101410275532',
    
'user_id' => 'tiaguim32',
    
'user_pwd' => '1234567',
    
'user_mail' => 'defdewfrwef',
    
'user_answer' => 'fdwefrfwefrwe',
    
'user_question' => 'efdwefewfewf',
    
'IP' => '1523615'
)); 
?>

Warning: mysqli::mysqli(): (HY000/1045): Access denied for user 'sa'@'localhost' (using password: YES) in C:\xampp\htdocs\MysqliDb.php on line 295

Fatal error: Uncaught exception 'Exception' with message 'Connect Error 1045: Access denied for user 'sa'@'localhost' (using password: YES)' in C:\xampp\htdocs\MysqliDb.php:298 Stack trace: #0 C:\xampp\htdocs\MysqliDb.php(377): MysqliDb->connect('default') #1 C:\xampp\htdocs\MysqliDb.php(1908): MysqliDb->mysqli() #2 C:\xampp\htdocs\MysqliDb.php(1519): MysqliDb->_prepareQuery() #3 C:\xampp\htdocs\MysqliDb.php(1459): MysqliDb->_buildQuery(NULL, Array) #4 C:\xampp\htdocs\MysqliDb.php(765): MysqliDb->_buildInsert('TBL_USER', Array, 'INSERT') #5 C:\xampp\htdocs\Processo2.php(13): MysqliDb->insert('TBL_USER', Array) #6 {main} thrown in C:\xampp\htdocs\MysqliDb.php on line 298
tiaguim is offline  
Old 05/28/2018, 01:39   #10


 
iMostLiked's Avatar
 
elite*gold: 1337
Join Date: Apr 2013
Posts: 6,487
Received Thanks: 3,190
Quote:
Originally Posted by tiaguim View Post
I had to change the credentials because they don't exist in myphpadmin...if i want to use those credentials i've to create a new user, and them it will give the same error saying that the table doesn't exist xD

PHP Code:
<?php
include('MysqliDb.php');
$db = new MysqliDb ('localhost''sa''1234''account');

$db->insert('TBL_USER', array(
    
'user_no' => '09101410275532',
    
'user_id' => 'tiaguim32',
    
'user_pwd' => '1234567',
    
'user_mail' => 'defdewfrwef',
    
'user_answer' => 'fdwefrfwefrwe',
    
'user_question' => 'efdwefewfewf',
    
'IP' => '1523615'
)); 
?>

Warning: mysqli::mysqli(): (HY000/1045): Access denied for user 'sa'@'localhost' (using password: YES) in C:\xampp\htdocs\MysqliDb.php on line 295

Fatal error: Uncaught exception 'Exception' with message 'Connect Error 1045: Access denied for user 'sa'@'localhost' (using password: YES)' in C:\xampp\htdocs\MysqliDb.php:298 Stack trace: #0 C:\xampp\htdocs\MysqliDb.php(377): MysqliDb->connect('default') #1 C:\xampp\htdocs\MysqliDb.php(1908): MysqliDb->mysqli() #2 C:\xampp\htdocs\MysqliDb.php(1519): MysqliDb->_prepareQuery() #3 C:\xampp\htdocs\MysqliDb.php(1459): MysqliDb->_buildQuery(NULL, Array) #4 C:\xampp\htdocs\MysqliDb.php(765): MysqliDb->_buildInsert('TBL_USER', Array, 'INSERT') #5 C:\xampp\htdocs\Processo2.php(13): MysqliDb->insert('TBL_USER', Array) #6 {main} thrown in C:\xampp\htdocs\MysqliDb.php on line 298
This is an error on the side of your server, check everything again. Are you sure that this user has full rights on this database? Is the password correct?
The script seems to work properly.
iMostLiked is offline  
Old 05/28/2018, 01:42   #11
 
tiaguim's Avatar
 
elite*gold: 0
Join Date: Apr 2010
Posts: 42
Received Thanks: 1
Quote:
Originally Posted by iMostLiked View Post
This is an error on the side of your server, check everything again. Are you sure that this user has full rights on this database? Is the password correct?
The script seems to work properly.
Even if not, the "Root" user should work right? Since by default is a super user with all rights over the datebase right


In the other script if i use root as user, gives this error

Warning: odbc_connect(): SQL error: [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'root'., SQL state 28000 in SQLConnect in C:\xampp\htdocs\Processo.php on line 11

Warning: mysql_select_db() expects parameter 2 to be resource, boolean given in C:\xampp\htdocs\Processo.php on line 18
Can't use account:

Pretty messed up ham? XDDDD



If i run the querry on the SQL server querry stuff, it goes normal...but theres is no point there...
tiaguim is offline  
Old 06/09/2018, 23:42   #12
 
elite*gold: 0
Join Date: Jun 2018
Posts: 2
Received Thanks: 0
Pretty simple.
Download sqlsrv microsoft driver (but check if you have thread safe or not) and add your info right there.
I can give you an example.

Quote:
/*
|--------------------------------------------------------------------------
| Mssql (SQL Server)
|--------------------------------------------------------------------------
|
| We do not recommend sa user as default user and add an firewall exception for your IP if you are
| hosting this website outside the machine where the server is being hosted.
| Holds the dekaron sql server information to make the changes in the
| game emulator tables
| Here are some steps to follow to make sure sqlsrv is loaded and this
| functionallity do not break!
| 1- Check the phpinfo() and check if we are in thread_safety or not
| 2- Download MSSQL Drivers according to the thread_safety
| 3- Extract to php libs the choosed dll example: php_sqlsrv54_ts.dll
| 4- Modify the php.ini and add this new extension like extesion=php_sqlsrv54_ts.dll
| 5- Enable SQL Server to listen in specific ports so we go to SQL Configuration Manager/Protocols/Properties and make sure it's enabled and which
| port it is listening
| 6- Restart both services (mysqld) and (mssql)
|
| P.S: In case you get unable to load function or invalid win32 dll you must change the architecture to x86 or vice versa
|
*/
$db['mssql'] = array(
'hostname' => '127.0.0.1',
'port' => 1433,
'username' => 'sa',
'password' => '1234',
'database' => 'account',
'dbdriver' => 'sqlsrv',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'autoinit' => TRUE
);
That's my config for my custom query builder class but just you have an idea of the basic things you need like user,host,port,db and pwd and so after you get an array or whatever to store that data you do a basic connection. (Make sure your mssql allow external connections and you have permission on that user)

Enigmacpp is offline  
Old 06/10/2018, 00:38   #13
 
tiaguim's Avatar
 
elite*gold: 0
Join Date: Apr 2010
Posts: 42
Received Thanks: 1
Thanks for the explanation! I came up with this working code!

PHP Code:
 <?php
$serverName 
"(local)";
$connectionInfo = array( "Database"=>"account""UID"=>"tiaguim""PWD"=>"1234" );
$connectionInfo2 = array( "Database"=>"cash""UID"=>"tiaguim""PWD"=>"1234" );
$conn sqlsrv_connect$serverName$connectionInfo);
$conn2 sqlsrv_connect$serverName$connectionInfo2);
if( 
$conn === false ) {
     die( 
print_rsqlsrv_errors(), true));
}
//Random numero do ID de utilizador
$dk_time=strftime("%y%m%d%H%M%S");
list(
$usec1$sec1) = explode(" ",microtime());
$dk_user_no=$dk_time.substr($usec1,2,2);

//Pegar valores do index
$UsuarioID $_POST['input1'];
$Password md5($_POST['input2']);
$Mail $_POST['input3'];
$Pergunt $_POST['input4'];
$Respost $_POST['input5'];

//Botăo Pressionado
if(isset($_POST['register'])){
    
$Loginsql "select user_id from Tbl_user where user_id='$UsuarioID'";
$params2 = array();
$options =  array( "Scrollable" => "buffered" );


$qLogin sqlsrv_query($conn$Loginsql$params2$options);
$rLogin sqlsrv_num_rows($qLogin);


$Mailsql "select user_mail from Tbl_user where user_mail='$Mail'";

$qEmail sqlsrv_query($conn$Mailsql$params2$options);
$rEmail sqlsrv_num_rows($qEmail);

if(empty(
$UsuarioID) || empty($Password) || empty($Mail) || empty($Pergunt) || empty($Respost)) {
echo 
"Preencha todos os campos corretamente, volte para a página <a href='http://25.81.112.243/Ryudekaron.html'> inicial <a/>";
}
elseif(
$rLogin >= 1){
die(
"Esse usuario já existe, volte para a página <a href='http://25.81.112.243/Ryudekaron.html'> inicial <a/>");
}
elseif(
$rEmail >= 1){
die(
"Esse email já existe, volte para a página <a href='http://25.81.112.243/Ryudekaron.html'> inicial <a/>");
}
else{

//Dia hora data
$dia = (strftime("%x %X"));



//Tbl_user
$sql "INSERT INTO Tbl_user (user_no, user_id, user_pwd, user_mail, user_answer, user_question, IP) VALUES (?,?,?,?,?,?,?)";
$params = array($dk_user_no$UsuarioID$Password$Mail$Respost$Perguntnull);

$stmt sqlsrv_query$conn$sql$params);
if( 
$stmt === false ) {
     die( 
print_rsqlsrv_errors(), true));
}

//USER_PROFILE
$sql2 "INSERT INTO USER_PROFILE (user_no, user_id, user_pwd, resident_no, user_type, login_flag, login_tag, ipt_time, login_time, logout_time, user_ip_addr, server_id) VALUES (?,?,?,?,?,?,?,?,?,?,CAST('?' AS VARBINARY(4)),?)";
$params2 = array($dk_user_no$UsuarioID$Password"801011000000""1""0""Y"$dianullnullnull"000");

$stmt2 sqlsrv_query$conn$sql2$params2);
if( 
$stmt2 === false) {
    die( 
print_rsqlsrv_errors(), true));
}

//user_cash
$sql3 "INSERT INTO user_cash (id, user_no, group_id, amount, free_amount) VALUES (?,?,?,?,?)";
$params3 = array($dk_user_no$dk_user_no,"01","10000","0" );

$stmt3 sqlsrv_query$conn2$sql3$params3);
if (
$stmt3 === false) {
    die( 
print_rsqlsrv_errors(), true));
}
Echo 
"Sua conta foi registada com sucesso!";
}
}
?>
Well, it works xD
tiaguim is offline  
Reply


Similar Threads Similar Threads
[RELEASE]PHP 5.4/PHP Driver 3.0(SQLSRV) Account Registration Module
04/14/2018 - Rappelz Private Server - 23 Replies
Hello Community, Today during some of my free time I was organizing some of my older projects that I plan to revise or revamp. I have long since seen many people here that are looking for proper registration scripts which this community is lacking in! Some of you may be using or may have used my ASPX script. But then again, some just don't want to tangle with ASPX and would prefer a more simplistic resolution to their registration difficulties, but you still want to remain protect no? ...
[Selling] Pre-registration reward for Summoners War: Rift of Worlds 1$ Pre-registration reward
12/15/2015 - Summoners War Trading - 0 Replies
“Summoners War: The Rift of Worlds” is now available! http://i.imgur.com/uZ71itv.png <Download Summoners War> http://m.withhive.com/b?i=9447&g=9446 <Get Pre-registration Reward> Autobuy: https://payivy.com/v/9a4ce
Phpbb3-Xauth Bridge [nutzt eure Foren Registration als In-Game User Registration]
12/02/2012 - Minecraft Guides & Strategies - 13 Replies
Phpbb3-Xauth Bridge Version 1.0 Alpa Ich habe das PhpBB3 so verändert das ihr es mit xAuth verwenden könnt Im Detail bedeutet das: Eure User müssen sich dann in eurem Forum Registrieren um auf eurem Server spielen zu können. Nach der Foren Registration sind diese dann automatisch In-Game registriert das hat zum Vorteil, das die User zwar etwas länger für die Registration brauchen ihr aber all eure User im Forum und In-Game unter dem gleichen Namen findet. Benötige Files Das...
[PHP] Create A Registration Website For An MMORPG Server
12/04/2007 - Web Development - 2 Replies
Is this correct? I get an error when i go to the website. I am using apache, postgre, php $con = pg_connect("host=".$pg." dbname=".$db." user=".$un." password=".$ps."", PGSQL_CONNECT_FORCE_NEW) or die("Error:".pg_last_error($con));



All times are GMT +1. The time now is 23:48.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.