<?php
class Registration extends MySQLi
{
public function __construct($Location = '', $Username = '', $Password = '', $DBname = '')
{
parent::__construct($Location, $Username, $Password, $DBname);
}
public function checkFormData($Username, $Password0, $Password1, $Email0, $Email1)
{
if (isset($Username) AND (!(empty($Username))))
{
if (!preg_match('/^[\w()[\]_.]+$/', $Username))
{
echo 'Username: Only a-z,A-Z,0-9, 3 - 30 letters, (), [] und .!<br>';
$CheckUsername = FALSE;
}
else
{
$CheckUsername = TRUE;
}
}
else
{
echo 'We need at least a Username!<br>';
}
if (isset($Password0) AND isset($Password1) AND (!(empty($Password0))) AND (!(empty($Password1))))
{
if (preg_match('/^\w{3,30}$/', $Password0) AND preg_match('/[a-zA-Z]/', $Password0) AND preg_match('/[0-9]/', $Password0))
{
if (!($Password0 === $Password1))
{
echo 'Passwords arent the same!<br>';
$CheckPassword = FALSE;
}
else
{
$CheckPassword = TRUE;
}
}
else
{
echo 'Password: Only a-z,A-Z,0-9, min 3 max 30 letters!<br>
At least one letter and one number!<br>';
}
}
else
{
echo 'We need at least the passwords!<br>';
}
if(isset($Email0) AND isset($Email1) AND (!(empty($Email0))) AND (!(empty($Email1))))
{
if(!($Email0 === $Email1))
{
echo 'Emails arent the same!<br>';
$CheckEmail = FALSE;
}
else
{
$CheckEmail = TRUE;
}
}
else
{
echo 'We need at least the Emails!<br>';
}
if ($CheckUsername === TRUE)
{
if ($CheckPassword === TRUE)
{
if ($CheckEmail === TRUE)
{
return TRUE;
}
else
{
return FALSE;
}
}
else
{
return FALSE;
}
}
else
{
return FALSE;
}
unset($CheckUsername, $CheckPassword, $CheckEmail);
}
public function checkSelectData($Username, $Email0)
{
if ($mysqli_stmt = parent::stmt_init())
{
$sql = 'SELECT
Username
FROM
user
WHERE
Username = ?';
$mysqli_stmt->prepare($sql);
$mysqli_stmt->bind_param('s', $Username);
$mysqli_stmt->execute();
$mysqli_stmt->bind_result($result);
if (!($mysqli_stmt->fetch()))
{
$checkit = TRUE;
}
else
{
echo 'username schon vergeben!<br>';
$checkit = FALSE;
}
if ($checkit === TRUE)
{
$sql = 'SELECT
Email
FROM
user
WHERE
Email = ?';
$mysqli_stmt->prepare($sql);
$mysqli_stmt->bind_param('s', $Email);
$mysqli_stmt->execute();
$mysqli_stmt->bind_result($result);
if (!($mysqli_stmt->fetch()))
{
return TRUE;
}
else
{
echo 'username okay aber email schon vorhanden!<br>';
return FALSE;
}
}
else
{
echo 'username and email schon vergeben!<br>';
return FALSE;
}
$mysqli_stmt->close();
}
else
{
return FALSE;
}
unset($checkit, $mysqli_stmt, $sql);
}
public function checkInsertData($Username, $Password0, $Email0)
{
if ($mysqli_stmt = parent::stmt_init())
{
$sql = 'INSERT INTO
user
SET
Username = ?, Password = ?, Email = ?';
$Password0 = md5($Password0);
$mysqli_stmt->prepare($sql);
$mysqli_stmt->bind_param('sss', $Username, $Password0, $Email0);
$mysqli_stmt->execute();
$mysqli_stmt->close();
return TRUE;
}
else
{
return FALSE;
}
unset($mysqli_stmt, $sql);
}
}
?>