Newbie Spellweaver
- Joined
- Jan 17, 2016
- Messages
- 56
- Reaction score
- 0
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.
PROBLEM: account exists and the code recreates it without problems.
PROBLEM: I have a ERROR but I can't see it, please check the code and post solutions.
thanks, waiting for answers = )
PROBLEM: account exists and the code recreates it without problems.
PROBLEM: I have a ERROR but I can't see it, please check the code and post solutions.
thanks, waiting for answers = )
PHP:
<?php
$login = $_REQUEST["login"];
$pass = $_REQUEST["pass"];
$md5_key = '2001';
$endPw = $md5_key . $pass;
$md5 = md5($endPw);
$serverName = "localhost";
$uid = "sa";
$pwd = "BLABLABLA";
$databaseName = "auth";
$connectionInfo = array( "UID"=>$uid, "PWD"=>$pwd, "Database"=>$databaseName);
?>
PHP:
<?php
require_once('includes/connection.php');
/* Connect using SQL Server Authentication. */
$conn = sqlsrv_connect( $serverName, $connectionInfo);
//Check if account exists
$accountExists = sqlsrv_num_rows(sqlsrv_query( $conn, "select login_name from dbo.Accounts where login_name='$_POST[login]'"));
if($accountExists > 0) echo "This account already exists<br/>";
else
{
$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','0','1','0','0','0')";
$stmt = sqlsrv_query( $conn, $tsql);if($stmt)
{
echo "Your account has been created<br />";
}
else
{
echo "An error has been occurred!<br />";
die( print_r( sqlsrv_errors(), true));
}
// Release resources.
sqlsrv_free_stmt($stmt);
sqlsrv_close($conn);
}
?>