将准备好的语句放入代码后,DB不会更新

时间:2017-04-17 01:13:29

标签: php mysql

所以我决定将准备好的语句放在我的代码中,当我用所有有效的详细信息填充信息时,会弹出一条消息,说明注册成功但实际上数据库中没有数据

这是我的功能代码;

        //check if form is submitted
        if (isset($_POST['signup'])) {
            $name = $_POST['name'];
            $email = $_POST['email'];
            $password = $_POST['password'];
            $cpassword = $_POST['cpassword'];



            //name can contain only alpha characters and space
            if (!preg_match("/^[a-zA-Z ]+$/",$name)) {
                $error = true;
                $name_error = "Name must contain only alphabets and space";
            }
            if(!filter_var($email,FILTER_VALIDATE_EMAIL)) {
                $error = true;
                $email_error = "Please Enter Valid Email ID";
            }
            if(strlen($password) < 6) {
                $error = true;
                $password_error = "Password must be minimum of 6 characters";
            }
            if($password != $cpassword) {
                $error = true;




          $cpassword_error = "Password and Confirm Password doesn't match";
            }
            if (!$error) 
            {
                // prepare and bind
                $stmt = $con->prepare("INSERT INTO users (name,email,password) VALUES (?, ?, ?)");
                $stmt->bind_param("sss", $name, $email, $password);
                if($stmt->execute = true) {

                    $successmsg = "Successfully Registered! <a href='login.php'>Click here to Login</a>";

                } else {
                    $errormsg = "Error in registering...Please try again later!";
                }

            }
        }


        ?>

我的php管理员中的Db结构;

        id(int 8)
        name(varchar 30)
        email(varchar 60)
        password(varchar 40)

我将非常感谢您的帮助,并提前致谢!

0 个答案:

没有答案