未定义索引:密码请帮助我在任何地方都看不到故障

问题描述

我知道这个问题曾经被问过很多次,但是看了好几个小时之后,我想我会向SO寻求帮助

我得到一个未定义的索引:密码错误,显然数据没有传递到数据库

这是我的PHP代码

$tech_register_error_message = '';
     $tech_register_success_message = '';
     if(isset($_POST['BtnAddTech'])) 
     {
         if ($_POST['tech_fname'] == "") {
            $tech_register_error_message = 'First Name is required!';
        } else if ($_POST['tech_lname'] == "") {
            $tech_register_error_message = 'Last Name is required!';        
        } else if ($_POST['tech_email'] == "") {
            $tech_register_error_message = 'Email is required!';     
        } else if (!filter_var($_POST['tech_email'],FILTER_VALIDATE_EMAIL)) {
            $tech_register_error_message = 'Invalid email address!';
        } else if ($app->isTechEmail($_POST['tech_email'])) {
            $tech_register_error_message = 'Email is already in use!';     
        } else if ($_POST['tech_contact'] == "") {
            $tech_register_error_message = 'Contact Number is required!';        
        } else if ($_POST['tech_jobrole'] == "") {
            $tech_register_error_message = 'Job Role is required!';       
         } else if ($_POST['tech_bio'] == "") {
            $tech_register_error_message = 'Bio is required!';    
         } else if ($_POST['password'] == "") { 
            $tech_register_error_message = 'Password is required!';   
         } else {
            $image_file = $_FILES["txt_file"]["name"];
            $type       = $_FILES["txt_file"]["type"];  
            $size       = $_FILES["txt_file"]["size"];
            $temp       = $_FILES["txt_file"]["tmp_name"];

            $path="tech-img/".$image_file;

            if(empty($image_file)){
                $tech_register_error_message = "Please Select Image";
            }
            else if($type=="image/jpg" || $type=='image/jpeg' || $type=='image/png' || $type=='image/gif')
            {   
                if(!file_exists($path)) 
                {
                    if($size < 5000000) 
                    {
                        move_uploaded_file($temp,"tech-img/" .$image_file); 
                    }
                    else
                    {
                        $tech_register_error_message="Your File To large Please Upload 5MB Size"; 
                    }
                }
                else
                {   
                    $tech_register_error_message="File Already Exists...Check Upload Folder"; 
                }
            }
            else
            {
                $tech_register_error_message="Upload JPG,JPEG,PNG & GIF File Formate.....CHECK FILE EXTENSION"; 
            }


            {

        $query = $db->prepare("INSERT INTO techs(tech_fname,tech_lname,tech_email,tech_contact,tech_jobrole,tech_bio,image_file,tech_password) VALUES (:tech_fname,:tech_lname,:tech_email,:tech_contact,:tech_jobrole,:tech_bio,:image_file,:tech_password");
                $query->bindParam("tech_fname",$tech_fname);
                $query->bindParam("tech_lname",$tech_lname);  
                $query->bindParam("tech_email",$tech_email);
                $query->bindParam("tech_contact",$tech_contact);
                $query->bindParam("tech_jobrole",$tech_jobrole);
                $query->bindParam("tech_bio",$tech_bio);
                $query->bindParam("image_file",$image_file);
                $enc_password = hash("sha256",$tech_password);
                $query->bindParam("tech_password",$enc_password,PDO::ParaM_STR);
                $query->execute();
                {
                    $tech_register_success_message="File Upload Successfully";


                }
            }
        }
    }

这是我的表格

<form method="post" action="" enctype="multipart/form-data">
    <div>
        <label>First Name</label>
        <input type="text" name="tech_fname">
    </div>
    <div>
        <label>Last Name</label>
        <input type="text" name="tech_lname">
    </div>
    <div>
        <label>Email</label>
        <input type="email" name="tech_email">
    </div>
      <div>
        <label>Telephone</label>
        <input type="number" name="tech_contact">
    </div>
    <div>
        <label>Job Role</label>
        <input type="text" name="tech_jobrole">
    </div>
    <div>
        <label>Bio</label>
        <textarea name="tech_bio"></textarea>
    </div>
    <div class="bottom-margin">
        <label>Upload Image</label>
        <input type="file" name="txt_file" class="form-control" accept="image/*"/>
    </div>
    <div>
        <label>Password</label>
        <input type="password" name="tech_password">
    </div>
    
    <div>
        <button type="submit" name="BtnAddTech">Submit</button>
    </div>
</form>

我知道这可能是一个男生的错误,但是我的眼睛受伤了,生存的意愿正在下降。

一如既往,非常感谢您的帮助,并在此先感谢您

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)