I know this has been asked many times before, but after looking at it for hrs and hrs I thought I would ask SO for help
I am getting a Undefined index: password error and obviously the data is not passing to the DB
here is my php code
$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";
}
}
}
}
And here is my form
<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>
I know its probably a school boy error, but my eyes hurt and the will to live is falling.
As always any help greatly appreciated and thank you in advance