[Release] Simple PHP Register

Reworked it, missing ALOT of checks. This should work, I don't have a server to test it on though.
 
Last edited by a moderator:
I don't really appreciate you removing that, I didn't have a copy of it. I assure you it wasn't though.

If you are talking about the password not being cleaned it actually is.. This removes everything that isn't a-z,A-Z,0-9.
Code:
preg_replace("/[^a-zA-Z\d ]/", "", $_POST['password'] != $_POST['password']

And for emails, filter_var is a built-in function of PHP.
Code:
filter_var([email protected], FILTER_VALIDATE_EMAIL)

So next time please actually look at what the script is doing before you remove it, you are just stifling creation in this board.

Also your script just lets anyone have passwords and emails up to the max char limit in the DB, and doesn't even check if the email is in a valid format.
 
Last edited:
I don't really appreciate you removing that, I didn't have a copy of it. I assure you it wasn't though.

If you are talking about the password not being cleaned it actually is.. This removes everything that isn't a-z,A-Z,0-9.
Code:
preg_replace("/[^a-zA-Z\d ]/", "", $_POST['password'] != $_POST['password']

Also your script just lets anyone have passwords and emails up to the max char limit in the DB, and doesn't even check if the email is in a valid format.

I actually have a backup of it on my desktop, i'll pm it to you in a few and i'll tell you where it can be exploited.

4 Beta
 
[h=2]Simple PHP Register[/h]I complete a config.php but error with server ($server = 'COMPUTER\\iPlayWarZ';) line.

I'll write when you get there ?

Sorry for bad english.
 
I really don't suggest using this, as I stated above the script just lets anyone have passwords and emails up to the max char limit in the DB, and doesn't even check if the email is in a valid format.

WooAf wont let me post my revised version because he doesn't understand regex.
 
I really don't suggest using this, as I stated above the script just lets anyone have passwords and emails up to the max char limit in the DB, and doesn't even check if the email is in a valid format.

WooAf wont let me post my revised version because he doesn't understand regex.

I do understand, your script is exploitable as ****, that's it

4 Beta
 
Fatal error: Call to undefined function mssql_connect() in /home/u274583998/public_html/includes/config.php on line 4

What is this ?
 
WooAf, you could actually be a helpful moderator.

StickGather, your PHP doesn't have the MSSQL extension installed.
 
Register Script with Email validation, Limits password to 25 characters but must be more than 6, made errors better, and now its using prepared statements. Didn't spend much time with it nor did I test it.

Replace all of index.php with:
PHP:
<?php
@session_start();
require_once('includes/config.php');
require_once('includes/functions.php'); 
if (isset($_POST['Submit']))
{
	$email = $_POST['email']);
	$password = $_POST['password']);
	$password2 = $_POST['password2']);

	if ($email == "" || $password == "" || $password2 == "") {

		$error .= '<center>Missing information</center><br />';

	} else {
		
		if (strlen($password) < 25 || strlen($password) > 6){

			$error .= "<center>Password must be less than 25 characters but more than 6.</center><br />";
		}

		if ($password != $password2) {

			$error .= '<center>Confirmation password do not match</center><br />';
		}

		if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {

		 	$error .= '<center>E-mail is not valid</center><br />';

	 	} else {

	 			//Query
				//Check if email already exist
				$statement = $pdo->prepare('SELECT * FROM Accounts WHERE email = :email');
				$statement->execute(array(':email' => $email));
				
				$rows = $statement->fetch(PDO::FETCH_ASSOC);

				if($rows) {

					$error .= '<center>Email already exist</center><br />';
				}

		}
	}

	if(!isset($error))
	{
		$statement = $pdo->prepare('EXEC WZ_ACCOUNT_CREATE :ip, :email, :password, 0, 0, 0,');

		$params = array(
					':ip'		=> $ip,
					':email' 	=> $email,
					':password' => $password
				);

		if($statement->execute($params)) {

			echo 'Account created!';
		}

	} else {

		echo $error;
	}
}
?>
<!--
This is only a sample script, you can remove, edit, what you want.
-->
<form method="post">
<center>
<fieldset>
<legend>Register</legend>

<!-- Email -->
<label for='email' >Email Address*:</label>
<input type='text' name='email' maxlength="50" /><br>

<!-- Password -->
<label for='password' >Password*:</label>
<input type='password' name='password' maxlength="50" /><br>

<!-- Confirm Password -->
<label for='password' >Confirm Password*:</label>
<input type='password' name='password2' maxlength="50" /><br>

<!-- Submit -->
<input type='submit' name='Submit' value='Register' />
</fieldset>
Coded by WooAf & Fixed by Secured for RZ
</center>
</form>

Replace all of config be sure to update it:
PHP:
<?php
//Edit this
$server = "";
$username = "";
$password = "";
$database = "";


//// Dont edit below /////

$ip = $_SERVER['REMOTE_ADDR'];

try {

  	$pdo = new PDO("sqlsrv:Server=".$server.";Database=".$database."", $username, $password);

} catch (PDOException $e) {

  	echo $e->getMessage();
}
?>
 
Last edited:
Back