Is procedural PHP a good approach for user registration and login system good for begginers? [closed]

17 hours ago 1
ARTICLE AD BOX

loginaction.php:

<?php include "db.php"; session_start(); if($_SERVER["REQUEST_METHOD"] == "POST"){ $email = $_POST["email"]; $password = $_POST["password"]; $sql = "SELECT * FROM user WHERE email = '$email'"; $result = $conn->query($sql); $result = $result->fetch_assoc(); if($result != null && password_verify($password, $result["password"])){ unset($result["password"]); $_SESSION["user"] = $result; header("Location: user.php"); } }

and here is my registeraction.php:

<?php include "db.php"; if($_SERVER["REQUEST_METHOD"] == "POST"){ $name = $_POST["name"]; $surname = $_POST["surname"]; $email = $_POST["email"]; $password = $_POST["password"]; $hashedPassword = password_hash($password, PASSWORD_DEFAULT); $sql = "SELECT id FROM user WHERE email = '$email'"; $check = $conn->query($sql); if(mysqli_num_rows($check) > 0){ echo "Jste již registrovaný na tento Email"; exit(); } $sql = "INSERT INTO user (name, surname, email, password) VALUES ('$name', '$surname', '$email', '$hashedPassword')"; $result = $conn->query($sql); header("Location: login.php"); }

is this the good way to approach the login and register? Its not for a big app, just my testing. How could I improve my skills more and what is the best way possible if I want to start making proffesional websites

Read Entire Article