|
You last visited: Today at 10:29
Advertisement
script account sqlsrv & php check before registering
Discussion on script account sqlsrv & php check before registering within the Rappelz Private Server forum part of the Rappelz category.
01/13/2016, 20:36
|
#1
|
elite*gold: 0
Join Date: Apr 2010
Posts: 11
Received Thanks: 0
|
script account sqlsrv & php check before registering
Good day friends , I 'm programming a code for registering new accounts , the code below works for me perfectly , but only need to do, check if the account exists, if the account exists give me a warning, else proceed with the registration.
thanks, waiting for answers = )
HTML Code:
<form action="reg.php" method="post" id="myform">
<span style="text-align: center">
<label for="login">Login</label>
<input id="login" name="login" class="text" />
</span>
<span style="text-align: center">
<label for="pass">Password</label>
<input id="pass" name="pass" class="password" />
</span>
<span style="text-align: center">
<input type="image" src="images/sendButton.png" class="send" />
</span>
<div class="clr"></div>
</form>
PHP Code:
<?php
$login = $_REQUEST["login"];
$pass = $_REQUEST["pass"];
$md5_key = '5dd23';
$endPw = $md5_key . $pass;
$md5 = md5($endPw);
$serverName = "localhost";
$uid = "admin";
$pwd = "123456789";
$databaseName = "auth";
$connectionInfo = array( "UID"=>$uid,
"PWD"=>$pwd,
"Database"=>$databaseName);
/* Connect using SQL Server Authentication. */
$conn = sqlsrv_connect( $serverName, $connectionInfo);
$tsql = "insert into dbo.Accounts (login_name, password, block, withdraw_remain_time, age, auth_ok, pcbang, last_login_server_idx, referral_id, referral_code, server_list_mask) values ('$login','$md5','0','0','18','1','1','1','0','0','0')";
/* Execute the query. */
$stmt = sqlsrv_query( $conn, $tsql);
if ( $stmt )
{
$something = "Submission successful.";
}
else
{
$something = "Submission unsuccessful.";
die( print_r( sqlsrv_errors(), true));
}
$output=$something;
/* Free statement and connection resources. */
sqlsrv_free_stmt( $stmt);
sqlsrv_close( $conn);
?>
|
|
|
01/13/2016, 21:17
|
#2
|
elite*gold: 0
Join Date: Jan 2014
Posts: 183
Received Thanks: 45
|
Quote:
Originally Posted by gresk3k
Good day friends , I 'm programming a code for registering new accounts , the code below works for me perfectly , but only need to do, check if the account exists, if the account exists give me a warning, else proceed with the registration.
thanks, waiting for answers = )
HTML Code:
<form action="reg.php" method="post" id="myform">
<span style="text-align: center">
<label for="login">Login</label>
<input id="login" name="login" class="text" />
</span>
<span style="text-align: center">
<label for="pass">Password</label>
<input id="pass" name="pass" class="password" />
</span>
<span style="text-align: center">
<input type="image" src="images/sendButton.png" class="send" />
</span>
<div class="clr"></div>
</form>
PHP Code:
<?php
$login = $_REQUEST["login"];
$pass = $_REQUEST["pass"];
$md5_key = '5dd23';
$endPw = $md5_key . $pass;
$md5 = md5($endPw);
$serverName = "localhost";
$uid = "admin";
$pwd = "123456789";
$databaseName = "auth";
$connectionInfo = array( "UID"=>$uid,
"PWD"=>$pwd,
"Database"=>$databaseName);
/* Connect using SQL Server Authentication. */
$conn = sqlsrv_connect( $serverName, $connectionInfo);
$tsql = "insert into dbo.Accounts (login_name, password, block, withdraw_remain_time, age, auth_ok, pcbang, last_login_server_idx, referral_id, referral_code, server_list_mask) values ('$login','$md5','0','0','18','1','1','1','0','0','0')";
/* Execute the query. */
$stmt = sqlsrv_query( $conn, $tsql);
if ( $stmt )
{
$something = "Submission successful.";
}
else
{
$something = "Submission unsuccessful.";
die( print_r( sqlsrv_errors(), true));
}
$output=$something;
/* Free statement and connection resources. */
sqlsrv_free_stmt( $stmt);
sqlsrv_close( $conn);
?>
|
U need to put an select query in it too which will check if account exists. And this script is not save about sql injections.
Tomorrow when im at my pc i will writte here my old php script.
|
|
|
01/13/2016, 21:38
|
#3
|
elite*gold: 0
Join Date: May 2011
Posts: 5,086
Received Thanks: 3,472
|
Try to use something like mysql_escape_string() (not the best solution tho) at least before inserting into the database.
I could get access to your server in a second if you keep it like that.
You should read about
|
|
|
01/13/2016, 23:24
|
#4
|
elite*gold: 0
Join Date: Apr 2010
Posts: 11
Received Thanks: 0
|
Quote:
Originally Posted by g_d_dragon
U need to put an select query in it too which will check if account exists. And this script is not save about sql injections.
Tomorrow when im at my pc i will writte here my old php script.
|
ok bro ty and please post here your script  ty again
|
|
|
01/14/2016, 05:30
|
#5
|
elite*gold: 0
Join Date: Jan 2014
Posts: 183
Received Thanks: 45
|
heres my Old PHP Regi, it was made with mssql plugin and it worked for me with xampp 1.7. u will need to change the mssql_paras.
You need the PHP Connection and HTML + PHP Code in the same Editor File
PHP Connection:
PHP Code:
<?php
$host = "IP"; // your sql instance
$user = "DBuser"; // username
$pw = "DBpwd"; // password
$db = "DB"; // db
$md5_key = "Salt"; // your md5 key
$connect = mssql_connect($host,$user,$pw)
or die("Can't connect to the datebase.");
mssql_select_db($db,$connect)
or die("Can't select the datebase");
session_start();
?>
HTML + PHP Code:
HTML Code:
<html>
<head>
<title>Rappelz Dragon Server</title>
<center>
<h3 style="color:red">Rappelz Dragon: Register Page</h3>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<style type="text/css">#error {color:#ff0000; list-style:none;}</style>
<form action="<?php echo $_SERVER['Registration.php']; ?>" method="POST">
<div style="width:436px; border:1px solid #000000; padding:16px;">
<body><strong><img src="drache01.jpeg" width="400" height="300" align="middle"></strong></body>
<div style="height: 5px;"> </div>
Username
<input name="username" value="<?php if(isset($_POST['username'])){ echo $_POST['username']; } ?>" style="width:100%;" />
<div style="height: 5px;"> </div>
Password
<input name="password" type="password" value="<?php if(isset($_POST['password'])){ echo $_POST['password']; } ?>" style="width:100%;" />
<div style="height: 5px;"> </div>
Confirm password
<input name="password2" type="password" value="<?php if(isset($_POST['password2'])){ echo $_POST['password2']; } ?>" style="width:100%;" />
<div style="height: 5px;"> </div>
Please enter the captcha code
<div style="height: 5px;"> </div>
<img src="captcha.php" alt="Captcha" title="Please type this in the text box below to prove you are human" width=140 height=40 />
<input type="text" name="captcha_code" size=10 />
<div style="height: 5px;"> </div>
<input type="submit" value="Create Account" />
</div>
</form>
<?php
$user_ip = $_SERVER['REMOTE_ADDR'];
$usr = isset($_POST['username']) ? trim($_POST['username']) : '';
$pass = isset($_POST['password']) ? trim($_POST['password']) : '';
$pass2 = isset($_POST['password2']) ? trim($_POST['password2']) : '';
$endPw = $md5_key . $pass;
$md5 = md5($endPw);
$results = mssql_query("SELECT * FROM dbo.Account WHERE '$usr' LIKE login_name");
$res = mssql_num_rows($results);
// Check if fiel Username is empty
if(trim($usr) == true)
{ // Lenght for Username (4 - 16)
if(strlen($usr) > 3 && strlen($usr) < 16)
{ // Check if fiel Password is empty
if(ctype_alnum($usr) === true)
{ // Only Numbers and Letters
if(trim($pass) == true)
{ // Lenght for Password (4 - 16)
if(strlen($pass) > 5 && strlen($pass) < 16)
{ // Only Numbers and Letters
if(ctype_alnum($pass) === true)
{ // Check if Passwords match
if($pass == $pass2)
{ // Checking Captcha
if ($_POST['captcha_code'] == $_SESSION['captcha_spam'])
{ // Checking if Account already exists
if($res > 0)
{echo "Account exists !";}
else
{mssql_query("INSERT INTO dbo.Account(login_name,password,referral_id,referral_code,pcbang,block,withdraw_remain_time,age,auth_ok,last_login_server_idx,event_code,server_list_mask,result,ip,game_code,gamecode,login_event) VALUES('$usr','$md5',0,0,0,0,0,18,1,0,0,0,0,0,0,0,0)");
echo "Registration success !";}
} else
{echo "Wrong captcha code.";}
} else
{echo "Passwords do not match.";}
} else
{echo "Password must consist of numbers and letters only.";}
} else
{echo "Password must be between 6 and 16 characters in length.";}
} else
{echo "Please provide a password.";}
} else
{echo "Username must consist of numbers and letters only.";}
} else
{echo "Username must be between 4 and 16 characters in length.";}
} else
{echo "Please provide a username.";}
?>
</center>
</head>
</html>
|
|
|
01/14/2016, 06:13
|
#6
|
elite*gold: 99
Join Date: Jun 2015
Posts: 289
Received Thanks: 114
|
I'd rather use .
|
|
|
01/15/2016, 02:19
|
#7
|
elite*gold: 0
Join Date: Apr 2010
Posts: 11
Received Thanks: 0
|
Quote:
Originally Posted by g_d_dragon
heres my Old PHP Regi, it was made with mssql plugin and it worked for me with xampp 1.7. u will need to change the mssql_paras.
You need the PHP Connection and HTML + PHP Code in the same Editor File
PHP Connection:
PHP Code:
<?php
$host = "IP"; // your sql instance
$user = "DBuser"; // username
$pw = "DBpwd"; // password
$db = "DB"; // db
$md5_key = "Salt"; // your md5 key
$connect = mssql_connect($host,$user,$pw)
or die("Can't connect to the datebase.");
mssql_select_db($db,$connect)
or die("Can't select the datebase");
session_start();
?>
HTML + PHP Code:
HTML Code:
<html>
<head>
<title>Rappelz Dragon Server</title>
<center>
<h3 style="color:red">Rappelz Dragon: Register Page</h3>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<style type="text/css">#error {color:#ff0000; list-style:none;}</style>
<form action="<?php echo $_SERVER['Registration.php']; ?>" method="POST">
<div style="width:436px; border:1px solid #000000; padding:16px;">
<body><strong><img src="drache01.jpeg" width="400" height="300" align="middle"></strong></body>
<div style="height: 5px;"> </div>
Username
<input name="username" value="<?php if(isset($_POST['username'])){ echo $_POST['username']; } ?>" style="width:100%;" />
<div style="height: 5px;"> </div>
Password
<input name="password" type="password" value="<?php if(isset($_POST['password'])){ echo $_POST['password']; } ?>" style="width:100%;" />
<div style="height: 5px;"> </div>
Confirm password
<input name="password2" type="password" value="<?php if(isset($_POST['password2'])){ echo $_POST['password2']; } ?>" style="width:100%;" />
<div style="height: 5px;"> </div>
Please enter the captcha code
<div style="height: 5px;"> </div>
<img src="captcha.php" alt="Captcha" title="Please type this in the text box below to prove you are human" width=140 height=40 />
<input type="text" name="captcha_code" size=10 />
<div style="height: 5px;"> </div>
<input type="submit" value="Create Account" />
</div>
</form>
<?php
$user_ip = $_SERVER['REMOTE_ADDR'];
$usr = isset($_POST['username']) ? trim($_POST['username']) : '';
$pass = isset($_POST['password']) ? trim($_POST['password']) : '';
$pass2 = isset($_POST['password2']) ? trim($_POST['password2']) : '';
$endPw = $md5_key . $pass;
$md5 = md5($endPw);
$results = mssql_query("SELECT * FROM dbo.Account WHERE '$usr' LIKE login_name");
$res = mssql_num_rows($results);
// Check if fiel Username is empty
if(trim($usr) == true)
{ // Lenght for Username (4 - 16)
if(strlen($usr) > 3 && strlen($usr) < 16)
{ // Check if fiel Password is empty
if(ctype_alnum($usr) === true)
{ // Only Numbers and Letters
if(trim($pass) == true)
{ // Lenght for Password (4 - 16)
if(strlen($pass) > 5 && strlen($pass) < 16)
{ // Only Numbers and Letters
if(ctype_alnum($pass) === true)
{ // Check if Passwords match
if($pass == $pass2)
{ // Checking Captcha
if ($_POST['captcha_code'] == $_SESSION['captcha_spam'])
{ // Checking if Account already exists
if($res > 0)
{echo "Account exists !";}
else
{mssql_query("INSERT INTO dbo.Account(login_name,password,referral_id,referral_code,pcbang,block,withdraw_remain_time,age,auth_ok,last_login_server_idx,event_code,server_list_mask,result,ip,game_code,gamecode,login_event) VALUES('$usr','$md5',0,0,0,0,0,18,1,0,0,0,0,0,0,0,0)");
echo "Registration success !";}
} else
{echo "Wrong captcha code.";}
} else
{echo "Passwords do not match.";}
} else
{echo "Password must consist of numbers and letters only.";}
} else
{echo "Password must be between 6 and 16 characters in length.";}
} else
{echo "Please provide a password.";}
} else
{echo "Username must consist of numbers and letters only.";}
} else
{echo "Username must be between 4 and 16 characters in length.";}
} else
{echo "Please provide a username.";}
?>
</center>
</head>
</html>
|
can you post the code modified to sqlsrv paras???
|
|
|
 |
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?
...
|
[Question]Script Check Please..Need a Prof.To Check This Script!
02/11/2014 - SRO Private Server - 6 Replies
Hello guys..
I want some of you to check this script and tell me if it works..or if there is any thing has to be modified or so...
It's a log procedure..that should Excute a query when a char lvls up.
USE
GO
/****** Object: StoredProcedure . Script Date: 02/09/2014 22:43:28 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
|
[ADVANCED] Registration Script / SQLSRV
01/06/2014 - Rappelz Private Server - 30 Replies
-- Forewarning --
The following is in no way shape or form intended for the use of beginners and requires basic and intermediate skill levels to apply and use.
-- Features --
Username Check
Password Confirm
Password MD5 Encryption
Age Field (For Server using; Adult Server)
|
Registering an account<--
04/08/2008 - Dekaron Private Server - 0 Replies
delted
|
All times are GMT +1. The time now is 10:30.
|
|