[Release] Simple PHP Register

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();
}
?>


USE PDO for mssql





iis log
C:\inetpub\logs\LogFiles\W3SVC1

php log
C:\Windows\Temp\php53_errors.log

## How to fix error
1.
$email = $_POST['email']);
$password = $_POST['password']);
$password2 = $_POST['password2']);

change to

$email = ( $_POST['email']);
$password = ( $_POST['password']);
$password2 = ( $_POST['password2']);


2.

if (strlen($password) < 25 || strlen($password) > 6){
change to
if (strlen($password) < 6 || strlen($password) > 24) {

3.
$statement = $pdo->prepare('EXEC WZ_ACCOUNT_CREATE :ip, :email, :password, 0, 0, 0,');
change to
$statement = $pdo->prepare('EXEC WZ_ACCOUNT_CREATE :ip, :email, :password, 0, 0, 0');


# Microsoft Drivers 3.0 for PHP for SQL Server
for PDO SQLSRC (8 files)
 
Last edited:
i have this problem if i try to open my 127.0.0.1/index.php
[h=2]HTTP-hiba: 500.0 - Internal Server Error[/h][h=3]A lap megjelenítése sikertelen, mert belső kiszolgálóhiba történt.[/h]
Részletes hibaadatok
FastCgiModule
ExecuteRequestHandler
PHP53_via_FastCGI
0x00000000

[TH="bgcolor: #EBEBEB, align: right"]Modul[/TH]

[TH="align: right"]Értesítés[/TH]

[TH="bgcolor: #EBEBEB, align: right"]Kezelő[/TH]

[TH="align: right"]Hibakód[/TH]

http://127.0.0.1:80/index.php
C:\inetpub\wwwroot\index.php
Névtelen
Névtelen


[TH="bgcolor: #EBEBEB, align: right"]Kért URL-cím[/TH]

[TH="align: right"]Fizikai elérési út[/TH]

[TH="bgcolor: #EBEBEB, align: right"]Bejelentkezési módszer[/TH]

[TH="align: right"]Bejelentkező felhasználó[/TH]

 
Hello can help me when I click book opens a webpage and error do not know can help me pack ?
Follow the on-screen print

:*:
 
Back