• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

[Release] Another PHP Registraion Form

Game Developer
Joined
Oct 1, 2005
Messages
420
Reaction score
47
My Code :)

PHP:
<html>
<head>
<title>GunZ User Account Register</title>
<style>
body {
	color: #003300;
	font-family: Verdana, Arial, Serif;
	font-size: 10pt;
}
input {
	border: 1px solid #003300;
	color: #003300;
	background: #DDDDDD; 
	font-family: Verdana, Arial, Serif;
	font-size: 10pt;
}
tr {
	font-size: 10pt;
}
a:link {
	text-decoration: none;
	color: #003300;
}
a:visited {
	text-decoration: none;
	color: #003300;
}
a:active {
	text-decoration: none;
	color: #003300;
}
a:hover {
	text-decoration: none;
	color: #FF6600;
}
</style>
</head>
<body>
<div align="center">
<?php
$srvip = "snaity.no-ip.org";
$srvport = "6000";
$mssql_user = "sa";
$mssql_pass = "******";
$mssql_database = "gunzsrv";
$mssql_host = "LOCALMACHINE\SQLEXPRESS";
$conn = mssql_connect($mssql_host, $mssql_user, $mssql_pass);
mssql_select_db($mssql_database);
?>
<FORM METHOD=POST ACTION="<?php echo $_SERVER['PHP_SELF']; ?>?act=register">
<table cellspacing=0 border=0>
<tr>
<td colspan=2 style="border: 1px solid #003300; background: #DDDDDD;"><CENTER><A HREF="<?php echo $_SERVER['PHP_SELF']; ?>">GunZ User Account Register</A></CENTER></td>
</tr>
<tr>
<td style="border-left: 1px solid #003300"> User ID:</td>
<td style="border-right: 1px solid #003300"><INPUT TYPE="text" NAME="login" ></td>
</tr>
<tr>
<td style="border-left: 1px solid #003300"> Password:</td>
<td style="border-right: 1px solid #003300"><INPUT TYPE="password" NAME="senha1"> </td>
</tr>
<tr>
<td style="border-left: 1px solid #003300"> Retype Password: </td>
<td style="border-right: 1px solid #003300"><INPUT TYPE="password" NAME="senha2"> </td>
</tr>
<tr>
<td style="border-left: 1px solid #003300"> Email:</td>
<td style="border-right: 1px solid #003300"><INPUT TYPE="text" NAME="email"> </td>
</tr>
<tr>
<td style="border: 1px solid #003300; border-top: 0px;" colspan=2><CENTER><INPUT NAME="Cadastrar" VALUE="Cadastrar" TYPE="submit"></CENTER></td>
</tr>
</table>
</FORM>
<?php

if ($_GET['act'] == 'register')
{
	$user = anti_injection($_POST['login']);
	$pass1 = anti_injection($_POST['senha1']);
	$pass2 = anti_injection($_POST['senha2']);
	$email = anti_injection($_POST['email']);
	if (valida(Array($user,$pass1,$pass2,$email)) == true)
	{
		if ($pass1 == $pass2)
		{
			if (ereg("([0-9,a-z,A-Z])", $user))
			{
				if (ereg("^([0-9,a-z,A-Z]+)([.,_]([0-9,a-z,A-Z]+))*[@]([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[.]([0-9,a-z,A-Z]){2}([0-9,a-z,A-Z])?$", $email))
				{
					$query = mssql_query("SELECT * FROM Accounts WHERE UserID='$user'");
					$num_rows = mssql_num_rows($query);
					if ($num_rows == 0)
					{
						$query = mssql_query("SELECT * FROM Accounts WHERE E_Mail='$email'");
					    $num_rows = mssql_num_rows($query);
						if ($num_rows == 0)
						{
							$query = mssql_query("INSERT INTO Accounts (UserID, Password, E_Mail) VALUES ('$user','$pass1','$email')");
							if (!$query)
							{
								echo ":: Error on account register try later ::<br>";
							}
							else
							{
								echo ":: Account has been registered ::<br>";
							}
						}
						else
						{
							echo ":: Email in use ::<br>";
						}
					}
					else
					{
						echo ":: User in use ::<br>";
					}
				}
				else
				{
					echo ":: Invalid Email ::<br>";
				}
			}
			else
			{
				echo ":: Only use Numbers and Letters in User ID ::<br>";
			}
		}
		else
		{
			echo ":: Password not equal with other ::<br>";
		}
	}
}

$query = mssql_query("SELECT * FROM Accounts");
$num_rows = mssql_num_rows($query);
echo "Total Accounts: ".$num_rows."<br>";

echo "<br><B>Server Status:</B> ";
$fp = @fsockopen($srvip, $srvport, $errno, $errstr, 1);
if (!$fp) {
    echo "<font style='color: #FF3300'><B>Offline</B></font></br>";
} else {
	echo "<font style='color: #009933'><B>Online</B></font></br>";
    fclose($fp);
}

// Função Anti Injection

function anti_injection($sql)
{
$sql = preg_replace(sql_regcase("/(from|select|insert|delete|where|drop table|show tables|#|\*|--|\\\\)/"),"",$sql);
$sql = trim($sql);
$sql = strip_tags($sql);
$sql = addslashes($sql);
return $sql;
}

// Verificar Campos Vazios

function valida($campos){
  foreach($campos as $c){
      if(empty($c)){
        echo ":: All fields needed ::<br>";
        return false;
      }else{
        return true;
      }
  }
}
?>
</div>
</body>
</html>
 
Last edited:
Newbie Spellweaver
Joined
Jul 22, 2004
Messages
38
Reaction score
0
this only work for your server?
</style>
</head>
<body>
<div align="center">
<?php
$srvip = "snaity.no-ip.org";
$srvport = "6000";
$mssql_user = "sa";
$mssql_pass = "******";
$mssql_database = "gunzsrv";
$mssql_host = "LOCALMACHINE\SQLEXPRESS";
$conn = mssql_connect($mssql_host, $mssql_user, $mssql_pass);
mssql_select_db($mssql_database);


do i have to change the $srvip = "snaity.no-ip.org"; to mine ?=P
 
Last edited:
Upvote 0
Junior Spellweaver
Joined
Oct 18, 2006
Messages
131
Reaction score
1
Preview:
Edit; doesnt work.
 
Last edited:
Upvote 0
Newbie Spellweaver
Joined
Apr 16, 2006
Messages
56
Reaction score
0
It chould be just my computer but when i try and make a ACC with it i get this:
Code:
Warning: mssql_query() [function.mssql-query]: message: Invalid column name 'UserID'. (severity 16) in C:\AppServ\www\index.php on line 92

Warning: mssql_query() [function.mssql-query]: Query failed in C:\AppServ\www\index.php on line 92

Warning: mssql_num_rows(): supplied argument is not a valid MS SQL-result resource in C:\AppServ\www\index.php on line 93

Warning: mssql_query() [function.mssql-query]: message: Invalid column name 'E_Mail'. (severity 16) in C:\AppServ\www\index.php on line 96

Warning: mssql_query() [function.mssql-query]: Query failed in C:\AppServ\www\index.php on line 96

Warning: mssql_num_rows(): supplied argument is not a valid MS SQL-result resource in C:\AppServ\www\index.php on line 97

Warning: mssql_query() [function.mssql-query]: message: Invalid column name 'UserID'. (severity 16) in C:\AppServ\www\index.php on line 100

Warning: mssql_query() [function.mssql-query]: message: Invalid column name 'Password'. (severity 16) in C:\AppServ\www\index.php on line 100

Warning: mssql_query() [function.mssql-query]: message: Invalid column name 'E_Mail'. (severity 16) in C:\AppServ\www\index.php on line 100

Warning: mssql_query() [function.mssql-query]: Query failed in C:\AppServ\www\index.php on line 100
:: Error on account register try later ::
Total Accounts: 0
Any iders on how to fix this?
 
Upvote 0
Newbie Spellweaver
Joined
Apr 16, 2006
Messages
56
Reaction score
0
Ok i chanegd a few things and now i am getting this:

Code:
Warning: mssql_query() [function.mssql-query]: message: Invalid column name 'E_Mail'. (severity 16) in C:\AppServ\www\index.php on line 96

Warning: mssql_query() [function.mssql-query]: Query failed in C:\AppServ\www\index.php on line 96

Warning: mssql_num_rows(): supplied argument is not a valid MS SQL-result resource in C:\AppServ\www\index.php on line 97

Warning: mssql_query() [function.mssql-query]: message: Invalid column name 'E_Mail'. (severity 16) in C:\AppServ\www\index.php on line 100

Warning: mssql_query() [function.mssql-query]: Query failed in C:\AppServ\www\index.php on line 100
:: Error on account register try later ::
Total Accounts: 0
 
Upvote 0
Newbie Spellweaver
Joined
Aug 22, 2004
Messages
28
Reaction score
0
Ok i chanegd a few things and now i am getting this:

Code:
Warning: mssql_query() [function.mssql-query]: message: Invalid column name 'E_Mail'. (severity 16) in C:\AppServ\www\index.php on line 96

Warning: mssql_query() [function.mssql-query]: Query failed in C:\AppServ\www\index.php on line 96

Warning: mssql_num_rows(): supplied argument is not a valid MS SQL-result resource in C:\AppServ\www\index.php on line 97

Warning: mssql_query() [function.mssql-query]: message: Invalid column name 'E_Mail'. (severity 16) in C:\AppServ\www\index.php on line 100

Warning: mssql_query() [function.mssql-query]: Query failed in C:\AppServ\www\index.php on line 100
:: Error on account register try later ::
Total Accounts: 0

u need to add the email column in account on the database
.
 
Last edited:
Upvote 0
Newbie Spellweaver
Joined
Jan 7, 2007
Messages
88
Reaction score
0
i get this error "Fatal error: Call to undefined function mssql_connect() in C:\wamp\www\WEB\index.php on line 47" any help???
 
Upvote 0
Junior Spellweaver
Joined
Apr 22, 2006
Messages
125
Reaction score
2
all these diff pages and i always get this error

"Parse error: parse error, unexpected '?' in C:\wamp\www\register.php on line 50"
any sugestons/help
 
Upvote 0
Newbie Spellweaver
Joined
Sep 5, 2005
Messages
32
Reaction score
0
Jesus christ. The undefined mssql_connect function is because you haven't enabled it. Open up php.ini (Use your goddarn search function) and remove the ; infront of extension=php_mssql.dll

GavinX, mind posting the code? Or is it the code from the 1st post?
 
Upvote 0
Back
Top