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!

PHP Register Script : How to add cash for item shop when registering ?

Initiate Mage
Joined
Feb 17, 2015
Messages
5
Reaction score
1
Hello, I have the files from https://forum.ragezone.com/f853/simple-php-register-script-1049880/
And I'd like to know how to also add cash for the item shop when I register on my website please ?
The SQL query for adding cash is this :
USE [DNMembership]
GO
DECLARE return_value int
EXEC return_value = [dbo].[P_ModCashBalance]
@nvcAccountName = N'USERNAME', IntCashBalance = 999999999
SELECT 'Return Value' = return_value
GO

How to execute it via php in the same files when registering please ?
Thank you :)



Thanks to @OuTDooR
sqlsrv_query($conn, "INSERT INTO dnmembership.dbo.Accounts (AccountName, AccountLevelCode, GameOption, CharacterCreateLimit, LastCharacterCreateDate, CharacterMaxCount, LastLoginDate, LastLogoutDate, LastLoginIP, LastSessionID, JoinIP, RegisterDate, PublisherCode, GenderCode, BirthDate, Passphrase, NationalityCode, ChannelPartnerCode, NewbieRewardFlag,SecondAuthLockFlag)VALUES ('$Username','99', NULL,'4', NULL,
'4', null, NULL, null,
null, null, GETDATE(), '4', null,
null, (SELECT HashBytes('MD5','$Password')), null, NULL,'true', CAST(0 AS bit)) DECLARE return_value int
EXEC return_value = [dbo].[P_ModCashBalance]
@nvcAccountName = N'$Username', IntCashBalance = 999999999
SELECT 'Return Value' = return_value") or die("That account already exists, try a different username.");
 
Junior Spellweaver
Joined
Mar 31, 2021
Messages
134
Reaction score
5
hello did you solve this i kinda need a nice scripts for the same reason but ..maybe to add the amount you want different occasion
 
Experienced Elementalist
Joined
Oct 18, 2020
Messages
206
Reaction score
39
can i ask what version are you using? 2126 or older ones?

I can share the php code here. But I need internet first.



PHP:
<!-- This uses latest php and Sqlsrv extension --><!-- I don't share the rest! --><!DOCTYPE html><html>	<head>		<title>REGISTER</title>		<style>		.container{			padding: 25px;			border: 1px solid #d43b5a;			width: 250px;			height: 320px;			margin-left: auto;			margin-right: auto;			text-align: center;			margin-top: 120px;			background: #010f2e;		}		input[type=text],[type=email],[type=password]{			margin-bottom: 20px;			border-radius: 5px 5px;			border: 1px solid #f5385e;			background: transparent;			color: #f5385e;		}		input[type=submit]{			cursor: pointer;			border: 1px solid #f5385e;			background: transparent;			border-radius: 10px 10px;			color: #f5385e;			height: 30px;			width: 120px;		}		.title{			color: #f5385e;		}		body{			background: #010f2e;		}		div{			display: block;		}		.alert{			padding: 5px;			margin-bottom: 20px;			border: 1px solid transparent;			border-radius: 4px;			height: 20px;			width: 240px;		}		.alert-warning{			color: #8a6d3b;			background-color: #fcf8e3;			bordor-color: #faebcc;		}		.alert-success{			color: #3c763d;			background-color: #dff0d8;			bordor-color: #d6e9c6;		}		.alert-danger{			color: #a94442;			background-color: #f2dede;			bordor-color: #ebccd1;		}		</style>	</head>	<body>	<div class="container">		<form action="" method="POST" autocomplete="off">		<h1 class="title">REGISTRATION</h1>			<?php				$serverName = "127.0.0.1, 1433"; //do not change already set and configured				$connectionInfo = array("UID"=>"sa", "PWD"=>"1234"); //use your sql LOGIN e.g "UID"=>"DragonNest", "PWD"=>"your database password"				$conn = sqlsrv_connect($serverName, $connectionInfo);				if($conn === false){					echo "<div class='alert alert-danger'>Unable to Istablish Connection to the database!</div>";				} 				if(isset($_POST['submit'])){					if(empty($_POST['username']) || empty($_POST['mail']) || empty($_POST['password']) || empty($_POST['repassword'])){						echo "<div class='alert alert-warning'>Please complete the required Fields!</div>";					} else {						if($_POST['password'] !== $_POST['repassword']){							echo "<div class='alert alert-warning'>Password didn't matched!</div>";						} else {							if(strlen($_POST['password']) < 6){								echo "<div class='alert alert-warning'>password is too short!</div>";							} else {								if(strlen($_POST['password']) > 15){									echo "<div class='alert alert-warning'>Password is too long!</div>";								} else {									if(!preg_match("#[0-9]+#", $_POST['password'])){										echo "<div class='alert alert-warning'>Password must include at least one number!</div>";									} else {										if(!preg_match("#[A-Z]+#", $_POST['password'])){											echo "<div class='alert alert-warning'>Password must include at least one Capitalized Letter!</div>";										} else {											if(!preg_match("#\W+#", $_POST['password'])){												echo "<div class='alert alert-warning'>Password must include at least one Special Character!</div>";											} else {												$checkmail = "SELECT mail FROM [DNMembership].[dbo].[Accounts] WHERE mail=?";												$mailparam = array($_POST['mail']);												$mailoption=  array("Scrollable" => SQLSRV_CURSOR_KEYSET);												$mailsql = sqlsrv_query($conn, $checkmail, $mailparam, $mailoption);												$mail_exist = sqlsrv_num_rows($mailsql);												if($mail_exist > 0){													echo "<div class='alert alert-warning'>" . $_POST['mail'] . " is already used!</div>";												} else {													$checkuser = "SELECT AccountName FROM [DNMembership].[dbo].[Accounts] WHERE AccountName=?";													$userparam = array($_POST['username']);													$useroption = array("Scrollable" => SQLSRV_CURSOR_KEYSET);													$usersql = sqlsrv_query($conn, $checkuser, $userparam, $useroption);													$user_exists = sqlsrv_num_rows($usersql);													if($user_exists > 0){														echo "<div class='alert alert-warning'>" . $_POST['username'] . " is already used!</div>";														} else {														$sql = "EXEC [DNMembership].[dbo].[__NX__CreateAccount] ?, ?, ?";														$param =  array($_POST['username'], $_POST['password'], $_POST['mail']);														$execute = sqlsrv_query($conn, $sql, $param);														$sqlcash = "EXEC [DNMembership].[dbo].[P_AddCashIncome] ?, 0, 0, 0, 500000";														$cashparam = array($_POST['username']);														$execute = sqlsrv_query($conn, $sqlcash, $cashparam);														if($execute === false){															echo "<div class='alert alert-danger'>Unable to Submit Data to the database!</div>";														} else {															echo "<div class='alert alert-success'>" . $_POST['username'] . " has been registered!</div>";														}													}												}											}										}									}								}							}						}					}				}			?>			<input type="text" name="username" placeholder="USERNAME">			<input type="email" name="mail" placeholder="E-MAIL">			<input type="password" name="password" placeholder="PASSWORD">			<input type="password" name="repassword" placeholder="RE-TYPE PASSWORD">			<input type="submit" name="submit" value="REGISTER">		</form>	</div>	</body></html>



just change the extension .txt to .php
 

Attachments

You must be registered for see attachments list
Last edited by a moderator:
Back
Top