Need help regarding register script.

Status
Not open for further replies.
Newbie Spellweaver
Joined
May 8, 2011
Messages
17
Reaction score
1
Would anyone kind provide a working register script for my v19 server? I'm trying to do a remote access from my webhost (hostgator) to my computer's MSSQL server. It seems after 48hours of trying I have failed my attempt. I'd like to ask for help from those people who actually has knowledge regarding this.
Would be nice as well if someone could reproduce what this person was trying to explain since his images are dead http://forum.ragezone.com/f144/remote-connect-mssql-server-826367/#post6883588

Though it seems the person in that thread had success.
 
Well an register script is not that hard to make.
The hardest thing is to configure MSSQL to work with external connections.

Well so far this is the script I'm using
<!-- Start Register -->


<?php

##Configuration##
$mssql_server = "ip\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 = "****"; //Hash code
$random_text_text = "e=mc2"; //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 -->

Do you think you can reproduce what that person was trying to explain on the link i provided?
Cause I've tested something and it seems I'm getting to same error using my remote webhost(hostgator) and using wamp itself. meanin whether I run the script on wamp or a remote host it gives me the same result. I can only conclude that there's a missing configuration that I did have not done yet which that person on that provided link could be on about.

Or at least provide me with a script that worked for you?
 
What kind of error do you get with that script?
If you tell me then i can look further into it

basically it's the same

Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: ip\SQLEXPRESs in /home/^^^^/public_html/register.php on line 23
Cannot connect to the MSSQL server.

which everyone else is having

I tried wamp I tried my remote host and it seems to be the same issue.

I've read every thread of people who had this same issue which was an overwhelming amount of threads (hence the 48 hours of research) and no success. That one thread left is the last thread I havent tried since whoever gave that fix seems to have dead links. Anyways if you are able to provide some help I'd really appreciate it.

Regards
 
You register script is ok. Its the configuration of sql express. Here this is what i found on google first hit



Thank you very much for that link you were very helpful that fixed my problem and everythings good now, the other errors I can simply do.
 
Status
Not open for further replies.
Back