注册表单php显示空字段

注册表单php显示空字段,php,Php,主席先生,我不是除了在php,我遵循了一个教程,并略有修改添加一些列,我遵循一英寸一英寸,当我测试运行它显示空字段时,我写错了什么,我使用的是xampp php v 5.3.0 <?php include "db.php"; class Process extends Database { public function verify_email($table,$email){ //abc@gmail.com// $re

主席先生,我不是除了在php,我遵循了一个教程,并略有修改添加一些列,我遵循一英寸一英寸,当我测试运行它显示空字段时,我写错了什么,我使用的是xampp php v 5.3.0

<?php    
include "db.php";

class Process extends Database
{
      public function verify_email($table,$email){
            //abc@gmail.com//
            $regexp = "/^[a-z0-9_-]+(\.[a-z0-9_-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/";
            if(!preg_match($regexp,$email)){
            return "invalid_email";
         }
         //Check email already exists or not
            $sql = "SELECT id FROM ".$table." WHERE u_email = '$email' LIMIT 1";
            $query = mysqli_query($this->con,$sql);
            $count = mysqli_num_rows($query);
            if($count == 1){
                return "already_exists";
            }else{
                return "ok";
            }
        }


        public function insert_record($table,$input){
            $sql = "";
            $sql .= "INSERT INTO ".$table." ";
            $sql .= "(".implode(",",array_keys($input)).") VALUES ";
            $sql .= "('".implode("','", array_values($input))."')";
            $query = mysqli_query($this->con,$sql);
            $last_id = mysqli_insert_id($this->con);
            if($query){
                return $last_id;
        }
    } 
        public function send_activation_code($email,$act_code){

        }
}
$obj = new Process;

    if(isset($_POST["check_email"])){
       $email = $_POST["email"];
       echo $data = $obj->verify_email("user_info",$email);
       exit();
}

    if(isset($_POST["u_email"])){
    echo $name = preg_replace("#[^A-Za-z]#i", "", $_POST["u_name"]);
    echo $age = preg_replace("#[^0-9]#", "", $_POST["age"]);
    echo $dateofbirth = preg_replace("#[^0-9]#", "", $_POST["dob"]);
    echo $gender = preg_replace("#[^a-z ]#i", "", $_POST["gender"]);
    echo $educationalqualification = preg_replace("#[^0-9A-Za-z ]#", "", $_POST["edq"]);
    $lang = $_POST["lang"];
    $count = COUNT($lang);
    $languages = "";
    for($i=0;$i<$count;$i++){
        $languages .= $lang[$i].",";
    }
    $languages = substr($languages, 0, -1);
    echo $languages = preg_replace("#[^A-Za-z,]#i", "", $languages);
    echo $mobile  = preg_replace("#[^0-9]#", "", $_POST["mobile"]);
    echo $whatsapp = preg_replace("#[^0-9]#", "", $_POST["whatsapp"]);
    echo $pincode = preg_replace("#[^0-9]#", "", $_POST["pincode"]);
    echo $district = preg_replace("#[^A-Za-z]#i", "", $_POST["district"]);
    echo $states = preg_replace("#[^A-Za-z]#i", "", $_POST["state"]);
    echo $country = preg_replace("#[^A-Za-z]#i", "", $_POST["country"]);
    echo $others = preg_replace("#[^A-Za-z]#i", "", $_POST["others"]);
    $data = $obj->verify_email("user_info",$_POST["u_email"]);
    if($data == "already_exists"){
        echo "Email Already Exists";
        exit();
    }else{
        echo $email = $_POST["u_email"];
    }
    echo $currentoccupation = preg_replace("#[^A-Za-z]#i", "", $_POST["current"]);
    echo $workexperience = preg_replace("#[^A-Za-z]#i", "", $_POST["work"]);
    echo $username = preg_replace("#[^A-Za-z0-9]#", "", $_POST["username"]);
    echo $password = $_POST["password"];
    echo $repassword = $_POST["repassword"];


    //Start Validation from here
    if(empty($name) || empty($age) || empty($dob) ||  empty($gender) ||   empty($educationalqualification) ||  empty($languages) || 
    empty($mobile) ||  empty($whatsapp) ||  empty($pincode) ||  empty($district) ||  empty($state) ||  empty($country) ||  
    empty($currentoccupation) || empty($workexperience) || empty($username) || empty($password)){
          echo "empty_fields";
        exit();
    }

        if(strlen($password) < 9){
        echo "password_too_short";
        exit();
    }
    if($password != $repassword){
        echo "password_not_same";
        exit();
    }else{
      //hash password
        $options = array('cost' => 12,);
        echo $hash_password =  password_hash($password,PASSWORD_DEFAULT, $options);
    }
    $signup_date = date("Y-m-d H:i:s");
    $act_code = time().md5($email).rand(50000,1000000);
    $act_code = str_shuffle($act_code);
    $user = array("u_name"=>$name,"dob"=>$dateofbirth,"age"=>$age,"gender"=>$gender,"edq"=>$educationalqualification,"languages"=>$languages,"mobile"=>$mobile,"whatsapp"=>$whatsapp,"pincode"=>$pincode,"district"=>$district,"state"=>$states,"country"=>$country,"u_email"=>$email,"current"=>$currentoccupation,"work"=>$workexperience,"username"=>$username,"password"=>$hash_password,"signup_date"=>$signup_date,"last_login"=>$signup_date,"act_code"=>$act_code,"activated"=>"0"); 
    $id = $obj->insert_record("user_info",$user);
    if($id){
        echo "Record Inserted Sucessfully";
    }
}

?>


警告:编写您自己的访问控制层并不容易,而且有很多机会使它严重出错。请不要编写您自己的身份验证系统,因为任何现代的同类产品都具有强大的内置功能。至少要遵循并永远不要将密码存储为纯文本或弱散列(如SHA1或MD5)。这种电子邮件验证正则表达式是完全错误的,会阻止很多人在您的站点注册。这些天你真正能做的就是检查地址中是否有
@
,如果有,尝试发送到地址。像
name@example.museum
存在,就像
θσερ@εχαμπλε.ψμ
一样。警告:尽可能使用准备好的语句,以避免在查询和创建过程中注入任意数据。在任何用户提供的数据都指定有
:name
指示符的情况下,这些都非常简单,以后将根据您使用的是哪一个指示符,使用
绑定参数或
执行该指示符填充该指示符。如果电子邮件必须是唯一的,强制执行此操作的最佳方法是在该列上使用
唯一的
约束。此处使用的方法易受攻击。不要使用如此愚蠢的regexp来过滤电子邮件。除此之外,您正在拒绝所有更新的GTLD与它。。。左手边也是完全错误的。你知道你可以有一个带+的地址吗?