Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$_POST not inserting values in the database

Tags:

post

php

mysql

I have a form. When the user submits, the values should insert in the database. Only the value of one $_POST is not inserted in the database, but the other $_POST's are inserting properly.

How to fix this?

HTML:

<input type="text" name="position" value="<?php echo $_POST['jobTitle']; ?>" id="position" required/>

PHP snippet:

$firstName = $middleName = $lastName = $email = $mobile = $resume = $position = $message = $attachment_id = $locations = "";

if(isset($_POST['submit'])){
    $firstName = isset($_POST['firstName']) ? $_POST['firstName'] : '';
    $middleName = isset($_POST['middleName']) ? $_POST['middleName'] : '';
    $lastName = isset($_POST['lastName']) ? $_POST['lastName'] : '';
    $email = isset($_POST['email']) ? $_POST['email'] : '';
    $mobile = isset($_POST['mobile']) ? $_POST['mobile'] : '';
    $locations = isset($_POST['locations_list']) ? $_POST['locations_list'] : '';
    $position = isset($_POST['jobTitle']) ? $_POST['jobTitle'] : '';
    $message = isset($_POST['message']) ? $_POST['message'] : '';
        if( ! empty($_FILES)){
            $file=$_FILES['resumeFile'];
            $attachment_id = upload_user_file($file);
        }

    $sql=$wpdb->query("INSERT INTO resume_databank(submit_time,last_name,first_name,middle_name,mobile_number,email,location,position,message,process_resume,attachment_resume_id) VALUES (now(),'$lastName','$firstName','$middleName','$mobile','$email','$locations','$position','$message','No','$attachment_id')");
}

exit();
like image 869
User014019 Avatar asked Aug 23 '26 13:08

User014019


1 Answers

Change this part

$position = isset($_POST['jobTitle']) ? $_POST['jobTitle'] : '';

to

$position = isset($_POST['position']) ? $_POST['position'] : '';

because in your form. your field name is position and $_POST['jobTitle']; is just a value

like image 128
Boby Avatar answered Aug 25 '26 04:08

Boby



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!