PHP & MySQL. User registration use script language to provide interactivity

PHP & MySQL. User registration

Step 1. Create webform for register a new user.

Step 2. In webform define attributes for passing data to php script.

Step 3. Write php script for process data of webform.

include 'globals.php';
include 'header.php'; 
    $userlogin = $_POST['userlogin'];
    $userpassword = $_POST['userpassword'];
    $usersurname = $_POST['usersurname'];
    $userfirstname = $_POST['userfirstname'];
    $usermobile = $_POST['usermobile'];

    $rezuser = mysqli_query($conn, "
        SELECT userID 
        FROM users 
        WHERE userlogin=$userlogin or usermobile=$usermobile");
    $myrow = mysqli_fetch_array($rezuser);
    if (!empty($myrow['userID'])){
        echo "This login or mobile are exist!";
        header("Refresh:2, url='signup.php'");
    $rezinsert = mysqli_query($conn, "INSERT INTO users(userlogin, userpassword, usersurname, userfirstname, usermobile) VALUE ('$userlogin', '$userpassword', '$usersurname', '$userfirstname', '$usermobile')");
        echo "Error";
        echo "New user is added successfully";

Step 4. Test registration form and check new data in database.

Категория: Relational databases | Добавил: bzfar77 (23.01.2023)
Просмотров: 17 | Теги: INSERT INTO, Select, php, webform, Post, registration | Рейтинг: 0.0/0
Всего комментариев: 0