register page error

Status
Not open for further replies.
Newbie Spellweaver
Joined
Apr 15, 2010
Messages
81
Reaction score
0
i got this error when i click submit

Code:
Warning: mssql_execute() [function.mssql-execute]: message: Could not find stored procedure 'createaccount'. (severity 16) in C:\Windows.old\Program Files\wamp\www\register.php on line 88

Warning: mssql_execute() [function.mssql-execute]: stored procedure execution failed in C:\Windows.old\Program Files\wamp\www\register.php on line 88
Error occurred while executing the statement.


this is the php code i use
PHP:
<!-- Start Register -->

<?php

#############################
##Copyright (c) TheJacob#####
##All Rights Reserved########
##[email protected]##
#############################

#############################
#############################

##Configuration##
$mssql_server = "johnjohn-PC\SQLEXPRESS"; //MSSQL server name or IP
$mssql_username = "sa"; //MSSQL username
$mssql_password = "********"; //MSSQL password
$mssql_account_db = "ACCOUNT_DBF"; //MSSQL account database name
$mssql_character_01_db = "CHARACTER_01_DBF"; //MSSQL character database name
$mssql_account_table = "account_tbl"; //MSSQL account table name
$mssql_username_column = "account"; //MSSQL username column in account table
$mssql_password_column = "password"; //MSSQL password column in account table
$hash = "serus"; //Hash code
$random_text_text = "rcs2105"; //Random text they must enter to register

#############################
#############################

##MSSQL Connect Function##
function mssql_connect_ini($mssql_server,$mssql_username,$mssql_password) {
$mssql_connect = mssql_connect($mssql_server, $mssql_username, $mssql_password) or die ("<strong>Cannot connect to the MSSQL server.</strong>");
	if ((strlen($mssql_server) == 0) || (strlen($mssql_username) == 0) || (strlen($mssql_password) == 0)) {
	echo "<strong>The connection configuration settings are invalid. Please make sure you've entered them in correctly.</strong>";
	}
}

##MSSQL Account Database Select Function##
function mssql_account_ini($mssql_account_db) {
$mssql_select_db = mssql_select_db($mssql_account_db) or die ("<strong>Cannot select the Account database.</strong>");
	if (strlen($mssql_account_db) == 0) {
	echo "<strong>The account database configuration setting is invalid. Please make sure you've entered it correctly.</strong>";
	}
}

#############################
#############################

##MSSQL Core Functionality##
mssql_connect_ini($mssql_server,$mssql_username,$mssql_password);
mssql_account_ini($mssql_account_db);

#############################
#############################

$pusername = @$_POST['username']; //Post wsername
$ppassword = @$_POST['password']; //Post password
$prpassword = @$_POST['rpassword']; //Post re-enter password
$random_text = @$_POST['random_text']; //Random text

if (isset($_POST['submit']) == true) {
$username = preg_replace("/[^a-zA-Z0-9\-\_\!\$\#\@\^\&\*\(\)\^\+\ \.\?]/", "", $pusername);
$password = preg_replace("/[^a-zA-Z0-9\-\_\!\$\#\@\^\&\*\(\)\^\+\ \.\?]/", "", $ppassword);

if ((isset($_POST['submit']) == true) and (strlen($pusername) < 3) || (strlen($pusername) > 15)) {
echo "Your username must be between 3 and 15 characters in length.";
}

else if ((isset($_POST['submit']) == true) and ((strlen($ppassword) < 3) || (strlen($ppassword) > 15) || (strlen($prpassword) < 3) || (strlen($prpassword) > 15))) {
echo "The password must be between 3 and 15 characters in length.";
}

else if ((isset($_POST['submit']) == true) and ($ppassword != $prpassword)) {
echo "The passwords must be the same.";
}

else if ((isset($_POST['submit']) == true) and (($pusername == $ppassword) || ($pusername == $prpassword))) {
echo "The username and password cannot be the same.";
}

else if ((isset($_POST['submit']) == true) and ($random_text != $random_text_text)) {
echo "The random text must be filled in correctly. Please take another look at the random text.";
}

else if (mssql_num_rows(mssql_query("SELECT * FROM $mssql_account_table WHERE $mssql_username_column = '$username'")) == '0') {
$stmt = mssql_init('createaccount');
mssql_bind($stmt, '@account', $username, SQLVARCHAR, false, false, 15);
mssql_bind($stmt, '@password', md5($hash . $password), SQLVARCHAR, false, false, 36);
mssql_execute($stmt) or die ("<strong>Error occurred while executing the statement.</strong>");
mssql_free_statement($stmt);
echo "You've been successfully registered as <strong>" . $username . "</strong>!";
} else {
echo "The username already exists.";
}
}

?>

<br>
<center>
<form method ="post" action="#">
<table>

<tr>
<td><strong>Username</strong></td>
</tr>
<tr>
<td><input name="username" type="username"></td>
</tr>
<tr>
<td><strong>Password</strong></td>
</tr>
<tr>
<td><input name="password" type="password"></td>
</tr>
<tr>
<td><strong>Re-enter Password</strong></td>
</tr>
<tr>
<td><input name="rpassword" type="password"></td>
</tr>
<tr>
<td><strong>Please enter "<?php echo $random_text_text ?>" without the brackets below</strong></td>
</tr>
<tr>
<td><input name="random_text" type="text"></td>
</tr>
<tr>
<td><input name="submit" type="submit" value="Register"></td>
</tr>

</table>
</form>
</center>

<!-- End Regiser -->
 
You have this error becuse you didn't have Reim's stored procedure :

Open Microsoft SQL Server, past this code as a Query, and execute. Then, you'll be able to use TheJacob's code :

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[createaccount]
@account VARCHAR(15),
@password VARCHAR(32)

AS

SET NOCOUNT ON

DECLARE @DateActivated AS CHAR(8)

IF NOT EXISTS (SELECT account FROM ACCOUNT_TBL WHERE account = @account) BEGIN
INSERT INTO ACCOUNT_TBL (account, [password], id_no2, isuse, member, realname)
VALUES (@account, @password, @password, 'T', 'A', 'F')

SET @DateActivated = CONVERT(CHAR(8), GETDATE()-1, 112 ) --Is the date today - 1
--UPDATE ACCOUNT_TBL_DETAIL SET BlockTime = @DateYesterday WHERE account = @userid
--INSERT INTO ACCOUNT_TBL_DETAIL (account, gamecode, tester, m_chLoginAuthority, regdate, BlockTime, EndTime, WebTime, isuse)
-- VALUES (@account, 'A000', '2', 'F', GETDATE(), '20990101', '20990101', '20050101', 'O')

INSERT INTO ACCOUNT_TBL_DETAIL (account, gamecode, tester, m_chLoginAuthority, regdate, BlockTime, EndTime, WebTime, isuse)
VALUES (@account, 'A000', '2', 'F', GETDATE(), @DateActivated, '20990101', '20050101', 'O')

END
 
Status
Not open for further replies.
Back