win7 ultimate 32bit
sql server 2008 management studio
appserv 2.6
i used this
LAN: 192.168.1.22
SQL id: godcn
SQL Pass: database55
config.php
Quote:
<?php
//User defined variables
$host = "192.168.1.22"; //Database Host. (IP to DB)
$user = "godcn"; //Database Username
$pass = "database55"; //Database Password
$link = mssql_connect($host,$user,$pass) or die('Connection Error.');
//Custom Function
function mssql_escape_string($data) {
if ( !isset($data) or empty($data) ) return '';
if ( is_numeric($data) ) return $data;
$non_displayables = array(
'/%0[0-8bcef]/', // url encoded 00-08, 11, 12, 14, 15
'/%1[0-9a-f]/', // url encoded 16-31
'/[\x00-\x08]/', // 00-08
'/\x0b/', // 11
'/\x0c/', // 12
'/[\x0e-\x1f]/' // 14-31
);
foreach ( $non_displayables as $regex )
$data = preg_replace( $regex, '', $data );
$data = str_replace("'", "''", $data );
return $data;
}
?>
index.php
verify.phpQuote:
<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Account Registration</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="jquery/QapTcha.jquery.css" type="text/css" />
<script type="text/javascript" src="jquery/jquery.js"></script>
<script type="text/javascript" src="jquery/jquery-ui.js"></script>
<script type="text/javascript" src="jquery/jquery.ui.touch.js"></script>
<script type="text/javascript" src="jquery/QapTcha.jquery.js"></script>
<script type="text/javascript" src="jquery/jquery.validate.min.js"></script>
<style type="text/css">
form{margin:30px;width:300px}
label{float:left;clear:both;width:100px;margin-top:10px}
input{float:left;margin-top:10px}
.clr{clear:both}
.notice {background-color:#d8e6fc;color:#35517c;border:1px solid #a7c3f0;padding:10px}
.code {
margin:30px;
border:1px solid #F0F0F0;
background-color:#F8F8F8;
padding:10px;
color:#777;
}
.error {color: red; font:10px arial,sans-serif;}
</style>
<script type="text/javascript">
$(document).ready(function(){
$("#reg").validate({
debug: false,
rules: {
UserID: "required",
Pw: "required",
Pw2: "required",
},
messages: {
UserID: "Please enter a Username.",
Pw: "Please provide a password.",
Pw2: "Please confirm your password.",
},
submitHandler: function(form) {
$.post('verify.php', $("#reg").serialize(), function(data) {
$('#results').html(data);
$('#UserID').val("");
$('#Pw').val("");
$('#Pw2').val("");
});
}
});
});
</script>
</head>
<body>
<h3>Shaiya Account Registration</h3>
<div id="results" style="list-style-type:none;"></div>
<?php
// if form is submit
if(isset($_POST['submit']))
{
$response = '<div class="notice">';
if(isset($_POST['iQapTcha']) && empty($_POST['iQapTcha']) && isset($_SESSION['iQaptcha']) && $_SESSION['iQaptcha'])
{
$response .= 'Form can be submited';
unset($_SESSION['iQaptcha']);
}
else
$response .= 'Form can not be submited';
$response .= '</div>';
echo $response;
}
?>
<form action="verify.php" id="reg" method="post">
<fieldset>
<label>Username</label> <input name="UserID" maxlength="16" id="UserID" />
<label>Password</label> <input type="password" id="Pw" maxlength="16" name="Pw" />
<label>Confirm Password</label> <input type="password" id="Pw2" maxlength="16" name="Pw2" />
<div class="clr"></div>
<div id="QapTcha"></div>
<input type="submit" name="submit" value="Register" />
</fieldset>
</form>
<script type="text/javascript">
$('#QapTcha').QapTcha({});
</script>
</body>
</html>
Code:
<?php
require_once('config.php');
$UserIp = $_SERVER['REMOTE_ADDR'];
$UserID = mssql_escape_string(trim($_POST['UserID']));
$Pw = mssql_escape_string(trim($_POST['Pw']));
$Pw2 = mssql_escape_string(trim($_POST['Pw2']));
$Error = array();
$Success=false;
if (isset($UserID,$Pw,$Pw2)) {
$Try = mssql_query("SELECT * FROM PS_UserData.dbo.Users_Master WHERE UserID = '{$UserID}'") or die('Failed to verify username in Users_Master.');
//Verify data exists
if(empty($UserID)){
$Error['UserID'] = 'Please provide a user name.';
}else if(strlen($UserID) < 3 || strlen($UserID) > 16){
$Error['UserID'] = 'Username must be between 3 and 16 characters in length.';
}else if(ctype_alnum($UserID) === false){
$Error['UserID'] = 'Username must consist of numbers and letters only.';
}else if(mssql_num_rows($Try)){
$Error['UserID'] = 'Username already exists, please choose a different username.';
}
if(empty($Pw)){
$Error['Pw'] = 'Please provide a password.';
}else if(strlen($Pw) < 3 || strlen($Pw) > 16){
$Error['Pw'] = 'Password must be between 3 and 16 characters in length.';
}else if($Pw != $Pw2){
$Error['Pw2'] = 'Passwords do not match.';
}
//Check for errors. If there is none, insert the account into the database.
if(count($Error) == 0){
mssql_query("INSERT INTO PS_UserData.dbo.Users_Master (UserID,Pw,JoinDate,Admin,AdminLevel,UseQueue,Status,Leave,LeaveDate,UserType,Point,UserIp) VALUES ('{$UserID}','{$Pw}',GETDATE(),0,0,0,0,0,GETDATE(),'N',0,'{$UserIp}')");
$Check = mssql_query("SELECT * FROM PS_UserData.dbo.Users_Master WHERE UserID = '{$UserID}'");
if(mssql_num_rows($Check) != 1){$Error[]='Failed to create account';}}
if(count($Error) != 0){foreach($Error as $Errors){echo "<li>".$Errors."</li>";}}else{echo "Account \"".$UserID."\" successfully created!";}
}
?>
when i try to register this is the result
Shaiya Account Registration
Fatal error: Call to undefined function mssql_connect() in C:\AppServ\www\reg\config.php on line 6






