Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (isset($_POST['submit'])) {
- $dbServername = "localhost";
- $dbUsername = "root";
- $dbPassword = "12345";
- $dbName = "loginsystem";
- $conn = mysqli_connect($dbServername, $dbUsername, $dbPassword, $dbName);
- $email = mysqli_real_escape_string($conn, $_POST['email']);
- $uid = mysqli_real_escape_string($conn, $_POST['felhasznalonev']);
- $pwd = mysqli_real_escape_string($conn, $_POST['jelszo']);
- $age = mysqli_real_escape_string($conn, $_POST['eletkor']);
- $nem= mysqli_real_escape_string($conn, $_POST['nem']);
- if (empty($email) || empty($uid) || empty($pwd) || empty($age) || empty($nem)) {
- header("Location: ../signuppage.php?signup=empty");
- exit();
- } else {
- if (!preg_match("/^[a-zA-Z]*$/", $uid)) {
- header("Location: ../signuppage.php?signup=invalid");
- exit();
- } else {
- if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
- header("Location: ../signuppage.php?signup=email");
- exit();
- } else {
- $sql = "SELECT * FROM users WHERE user_uid=?";
- $stmt = mysqli_stmt_init($conn);
- if(!mysqli_stmt_prepare($stmt, $sql)) {
- header("Location: ../index.php?login=error");
- exit();
- } else {
- mysqli_stmt_bind_param($stmt, "s", $uid);
- mysqli_stmt_execute($stmt);
- mysqli_stmt_store_result($stmt);
- $resultCheck = mysqli_stmt_num_rows($stmt);
- if ($resultCheck > 0) {
- header("Location: ../signuppage.php?signup=usertaken");
- exit();
- } else {
- $hashedPwd = password_hash($pwd, PASSWORD_DEFAULT);
- $sql = "INSERT INTO users (user_email, user_uid, user_pwd, user_age, user_nem)
- VALUES ('?', '?', '?', '?', '?');";
- $stmt2 = mysqli_stmt_init($conn);
- if(!mysqli_stmt_prepare($stmt2, $sql)) {
- header("Location: ../index.php?login=error");
- exit();
- } else {
- mysqli_stmt_bind_param($stmt2, "sssss", $email, $uid, $hashedPwd, $age, $nem);
- mysqli_stmt_execute($stmt2);
- header("Location: ../signuppage.php?signup=success");
- exit();
- }
- }
- }
- }
- }
- }
- mysqli_stmt_close($stmt);
- mysqli_stmt_close($stmt2);
- } else {
- header("Location: ../signuppage.php");
- exit();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement