string数据转换:使用mysql从spinner插入数据

mfpqipee  于 2021-06-21  发布在  Mysql
关注(0)|答案(0)|浏览(239)

我试图通过spinner将数据添加到mysql数据库中,spinner有几个选项可供选择。我不知道如何在mysql代码中声明spinner的值。错误发生在第39行,这是使用mysql代码插入数据库的第一行。我期待着尽快收到你的来信。

<?php

include 'db.php';    

        $user_type = ['user_type'];
        $first = $_POST['first'];
        $last = $_POST['last'];
        $email = $_POST['email'];
        $username = $_POST['username'];
        $password = $_POST['password'];
        $phone = $_POST['phone']; 

        if(/*$user_type == '' ||*/ $first == '' || $last == '' || $email == '' || $username == ''  || $password == '' || $phone == '')
        {
            echo 'Please, fill all fields';

        } else{
                $sql = "SELECT * FROM users WHERE user_username='$username'";
                $check = mysqli_fetch_array(mysqli_query($conn,$sql));
            if(isset($check))
            {
                    echo 'Username already exist. Please, use another one.';
            }else{
                        $hashedPWD = password_hash($password , PASSWORD_DEFAULT); //hash password

                        $sql = "INSERT INTO users (user_type, user_first, user_last, user_email, user_username, user_pwd, user_phonenumber) VALUES('$user_type','$first','$last','$email','$username','$hashedPWD','$phone')";
                    if(mysqli_query($conn,$sql))
                    {
                        echo 'Successfully registered';

                    } else{

                        echo 'Oops! Please try again!';
                        }   
                    }

            mysqli_close($conn);
        }

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题