php - 未定义的索引:密码请帮助我在任何地方都看不到故障
问题描述
我知道这已经被问过很多次了,但是在看了几个小时之后,我想我会向 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>
我知道这可能是一个男生的错误,但我的眼睛受伤了,生活的意愿也在下降。
与往常一样,非常感谢您的帮助,并在此先感谢您
解决方案
推荐阅读
- javascript - Is this the right way to import gsap in vue.js (it works but is it the "right" way?)
- javascript - jquery tabs - want to use more than once on same page
- c++ - 将 QObject 转换为 void 指针和从 void 指针丢失数据?
- typescript - Accept keyof of an object with a specific type?
- python-3.x - webscraping error with python3 only with some websites
- c++ - How to match all string types with std::is_same_v
- python-3.x - Boto3 different outputs
- python - Pygame Bouncy Ball Sinks Through Floor
- javascript - How to modify code so it doesn't run on reload?
- javascript - how to get the list of elements matching attribute from HTMLDivElement?