Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Shaiya > Shaiya Private Server
You last visited: Today at 18:09

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

Advertisement



HELP!!! Register with Email error

Discussion on HELP!!! Register with Email error within the Shaiya Private Server forum part of the Shaiya category.

Reply
 
Old   #1
 
st.jimmy998's Avatar
 
elite*gold: 0
Join Date: Jan 2013
Posts: 347
Received Thanks: 137
HELP!!! Register with Email error

I'm using this script with sql 2008r2 and xampp php 5.6

Code:
Warning: sqlsrv_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\Registro\register.php on line 32

Warning: sqlsrv_query() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\Registro\register.php on line 63
Failed to create a new account, please try again later
Warning: sqlsrv_close() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\Registro\register.php on line 87
register.php

Code:
<?php
require_once("PHPMailer/class.phpmailer.php");
require_once("recaptchalib.config.php");
require_once("recaptchalib.php");
require_once("config.php");

$user_ip = $_SERVER["REMOTE_ADDR"];
$username = isset($_POST["username"]) ? sqlsrv_escape_string(trim($_POST["username"])) : "";
$password = isset($_POST["password"]) ? sqlsrv_escape_string(trim($_POST["password"])) : "";
$password2 = isset($_POST["password2"]) ? sqlsrv_escape_string(trim($_POST["password2"])) : "";
$email = isset($_POST["email"]) ? sqlsrv_escape_string(trim($_POST["email"])) : "";
$verifyKey = isset($_GET["verifyKey"]) ? sqlsrv_escape_string(trim($_GET["verifyKey"])) : "";
$errors = array();
$success = "";
$activationKey =  mt_rand() . mt_rand() . mt_rand() . mt_rand() . mt_rand();

if (isset($_POST["submit"])) {
	$conn = sqlsrv_connect($db_host, $connectionInfo);
	$sql = "SELECT UserID FROM PS_UserData.dbo.Users_Master WHERE UserID = ?";
	
	$params = array($username);
	$options = array("Scrollable" => SQLSRV_CURSOR_KEYSET);
	$result = [MENTION=806297]sql[/MENTION]srv_query($conn, $sql, $params, $options);
	
	//Validate username
	if(empty($username)) {
		$errors["username"] = "Please provide a user name.";
	} else if(strlen($username) < 3 || strlen($username) > 16) {
		$errors["username"] = "User name must be between 3 and 16 characters in length.";
	} else if(ctype_alnum($username) === false) {
		$errors["username"] = "User name must consist of numbers and letters only.";
	} else if(sqlsrv_num_rows($result)) {
		$errors["username"] = "User name already exists, please choose a different user name.";
	}
	
	//Validate user password.
	if(empty($password)) {
		$errors["password"] = "Please provide a password.";
	} else if(strlen($password) < 3 || strlen($password) > 16) {
		$errors["password"] = "Password must be between 3 and 16 characters in length.";
	} else if($password != $password2) {
		$errors["password2"] = "Passwords do not match.";
	}
	
	// Validate Email and Answer
	if(empty($email)) {
		$errors["email"] = "Please provide your email.";
	} else if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
		$errors["email"] = "Invalid email format"; 
	}
	
	
	// Add the new account to the database if no previous errors have occurred.
	if(count($errors) == 0) {
		// AddUser Query & Parameters
		$addUser = "INSERT INTO PS_UserData.dbo.Users_Master(UserID,Pw,JoinDate,Admin,AdminLevel,UseQueue,Status,Leave,LeaveDate,UserType,Point,UserIp) VALUES (?,?,GETDATE(),0,0,0,-5,0,GETDATE(),'N',0,?)";
		$addUser_params = array($username, $password, $user_ip);
		
		// VerifyUser Query & Parameters
		$verifyUser = "INSERT INTO PS_UserData.dbo.User_Verification(UserID, VerifyKey, email) VALUES(?, ?, ?)";
		$verifyUser_params = array($username, $activationKey, $email);
		
		if(sqlsrv_query($conn, $addUser, $addUser_params) && sqlsrv_query($conn, $verifyUser, $verifyUser_params)) {
			$success = "Account ".$username." successfully created!";
		} else {
			$errors["query"] = "Failed to create a new account, please try again later";
		}
		
		$mail_for = "register";
		require_once("mail.php");
		
		if($mail->Send()) {
			$success .= "<br>An email has been sent to ".$email." with an activation key. Please check your mail to complete registration. <br />If the email is not in your main inbox please check you're spam folder or disable spam filtering.";
		} else {
			$errors["emailsend"] = "Validation email failed to send. Contact an administrator.";
		}
	}
	
	if(count($errors) != 0){
		foreach($errors as $error) {
			echo $error;
		}
	} else {
		echo $success;
	}

	sqlsrv_close($conn);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<?php 
		require_once('recaptchalib.config.php');
		require_once('recaptchalib.php');
		?>
		<title>Registration</title>
		<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>
		<script type="text/javascript">var RecaptchaOptions = {theme:'clean'};</script>
	</head>
	<body>
		<h3>Account Registration</h3>
		<form action="" method="post">
			<div style="width:436px; border:1px solid #000000; padding:16px;">
				Username
				<input name="username" value="<?php if(isset($_POST['username'])){ echo $_POST['username']; } ?>" style="width:100%;" />
				<div style="height: 5px;">&nbsp;</div>
				Password							
				<input name="password" type="password" value="<?php if(isset($_POST['password'])){ echo $_POST['password']; } ?>" style="width:100%;" />
				<div style="height: 5px;">&nbsp;</div>
				Confirm Password							
				<input name="password2" type="password" value="<?php if(isset($_POST['password2'])){ echo $_POST['password2']; } ?>" style="width:100%;" />
				<div style="height: 5px;">&nbsp;</div>
				Email				
				<input name="email" style="width:100%;" />
				
				<div style="height: 5px;">&nbsp;</div>
				<input type="submit" name="submit" value="Create Account" />
			</div>
		</form>
	</body>
</html>
st.jimmy998 is offline  
Reply


Similar Threads Similar Threads
Account register absichern / Safer Account Register
11/23/2018 - Shaiya PServer Development - 6 Replies
Hi ich hab eine Frage: wie muss ich das script so schreiben das es durch eine Captcha abfrage sicherer ist . Script siehe Spoiler<html> <head> <title>Register Page </title> <style type="text/css"> label {color: #000000;width: 10em;float: left;text-align: right;margin-right: 0.5em;display: block} .submit input{margin-left: 4.5em;} input,select{color: #000000;background: #ffffff;border: 1px solid #5d90bf} .submit input{color: #000000;background: #5d90bf;border: 2px outset
pvp server register button no funciona help - register button does not work help
12/02/2014 - DarkOrbit - 1 Replies
He instalado el servidor register button no funciona ¡ayuda ********************** I installed server register button does not work help **********************
why i cant register? how to register btw?
06/09/2012 - Rohan - 0 Replies
Registration denied, this forum runs an active policy of not allowing spammers. Please contact us via the "Contact Us" page link if you believe this is in error. i register 2 times and the mssg always shown.. some1 have solutions? Xor Rohan
Inline Asm -> Wert aus Register in anderes Register schreiben
03/17/2012 - C/C++ - 17 Replies
Huhu, die Frage klingt vielleicht etwas Blöd, aber ich würde gerne wissen, wie ich den Wert eines Registers in ein anderes schreiben kann. Wenn ich mov verwende wird lediglich die Speicheradresse auf das andere Register geschrieben und ich brauche den Wert in die Speicheradresse die mein Register hält. Mein Inline Asm Code sieht folgendermaßen aus: char *command; code = "insert 1"; _asm {
[Help] need help here register query error
01/22/2009 - EO PServer Hosting - 3 Replies
i cant querry my register account it has error when i run the queryy its says Table account.account doesnt exist. anyboby?



All times are GMT +1. The time now is 18:10.


Powered by vBulletin®
Copyright ©2000 - 2026, 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 ©2026 elitepvpers All Rights Reserved.