<?php
session_start();
$dsn = 'mysql:host=localhost;dbname=tsecret1_users;';
$pdo = new PDO($dsn, 'tsecret1_Sys', 'i$Q5****.2m.');
//Переменные
$email = $_POST['email'];
$pass = $_POST['pass'];
$pass2 = $_POST['pass2'];
$pass2_hash = hash("sha256", $pass2);
$session = hash("sha512", $email);
$email_base64 = base64_encode($email);
$sql = 'SELECT * FROM `Exiting Users` WHERE email = ?';
$query = $pdo->prepare($sql);
$query->execute([$email]);
$row = $sql->fetchAll;
$num_rows = count($row);
echo $num_rows;
if ($num_rows == 0) {
if ($pass == $pass2) {
//Регистрация
$sql = 'INSERT INTO `Exiting Users`(`email`) VALUES (:email)';
$query = $pdo->prepare($sql);
$query->execute(["email" => $email]);
$sql = 'CREATE TABLE `tsecret1_users`.`:email` ( `PassWord` TEXT NOT NULL ) ENGINE = MyISAM';
$query = $pdo->prepare($sql);
$query->execute(["email" => $email]);
$sql = 'INSERT INTO `:email`(`PassWord`) VALUES (:pass2_hash)';
$query = $pdo->prepare($sql);
$query->execute(["email" => $email, "pass2_hash" => $pass2_hash]);
$sql = 'ALTER TABLE `:email` ADD `parameters` TEXT NOT NULL AFTER `PassWord`';
$query = $pdo->prepare($sql);
$query->execute(["email" => $email]);
$sql = 'INSERT INTO `?`(`parameters`) VALUES (`EmailIsNotVerified`)';
$query = $pdo->prepare($sql);
$query->execute([$email]);
//Открытие сессии
$sql = 'ALTER TABLE `:email` ADD `Sessions` TEXT NOT NULL AFTER `parameters`';
$query = $pdo->prepare($sql);
$query->execute(["email" => $email]);
$sql = 'INSERT INTO `:email`(`Sessions`) VALUES (`:session`)';
$query = $pdo->prepare($sql);
$query->execute(["session" => $session]);
}
}
?>