We help IT Professionals succeed at work.

i am unable to add data to mysql database

Last Modified: 2017-04-08
$firstname = $_POST['firstname'];
      echo 'Your firstname is ' .$firstname. '<br>';
      $secondname = $_POST['secondname'];
      echo 'Your secondname is ' .$secondname. '<br>';
      $location = $_POST['location'];
      echo 'Your location is ' .$location. '<br>';
      $designation = $_POST['designation'];
      echo 'Your designation is ' .$designation. '<br>';
      $fileno = $_POST['fileno'];
      echo 'Your fileno is ' .$fileno. '<br>';
      // date to display
    $rawdate = htmlentities($_POST['doa']);
    $doa = date('Y-m-d', strtotime($rawdate));
      echo 'Your dateofapplication is ' .$doa. '<br>';
    $rawdate = htmlentities($_POST['doj']);
    $doj = date('Y-m-d', strtotime($rawdate));
      echo 'Your dateofjoining is ' .$doj. '<br>';
      $door1 = $_POST['door1'];
      echo ' dooraccess is available for ' .$door1. '<br>';
      $door2 = $_POST['door2'];
      echo 'dooraccess is available for  ' .$door2. '<br>';

      $door3 = $_POST['door3'];
      echo 'dooraccess is available for  ' .$door3. '<br>';

    $door4 = $_POST['door4'];
      echo 'dooraccess is available for  ' .$door4. '<br>';
      $door5 = $_POST['door5'];
      echo 'dooraccess is available for  ' .$door5. '<br>';
      $door6 = $_POST['door6'];
      echo 'dooraccess is available for  ' .$door6. '<br>';
      $door7 = $_POST['door7'];
      echo 'dooraccess is available for  ' .$door7. '<br>';
      $door8 = $_POST['door8'];
      echo 'dooraccess is available for  ' .$door8. '<br>';
      $door9 = $_POST['door9'];
      echo 'dooraccess is available for  ' .$door9. '<br>';
      $door10 = $_POST['door10'];
      echo 'dooraccess is available for  ' .$door10. '<br>';
      $door11 = $_POST['door11'];
      echo 'dooraccess is available for  ' .$door11. '<br>';
      $door12 = $_POST['door12'];
      echo 'dooraccess is available for  ' .$door12. '<br>';
      // commments to display       
   //$comments = $_POST['comments'];
   //echo 'Your comments is ' .$comments. '<br>';
      // Getting the form variable fileno and then placing their values into the MySQL table
      //$fileno = $_POST['fileno'];
      //echo 'Your fileno is ' .$fileno. '<br>';
      // date to display
    //$rawdate = htmlentities($_POST['date']);
    //$date = date('Y-m-d', strtotime($rawdate));
      //echo 'Your comments is ' .$date. '<br>';
   //email to display
     //$email = $_POST['email'];
     //echo 'Your email is ' .$email. '<br>';

//if (!empty($_POST['firstname']) && !empty($_POST['secondname'])&& !empty($_POST['location'])&& !empty($_POST['designation']) && !empty($_POST['fileno']) && !empty($_POST['card1'])  && !empty($_POST['card2']) && !empty($_POST['cardgrrd'])&& !empty($_POST['door1']) && !empty($_POST['door2']) && !empty($_POST['door3']) && !empty($_POST['door4']) && !empty($_POST['door5']) && !empty($_POST['door6']) && !empty($_POST['door7']) && !empty($_POST['door8']) && !empty($_POST['door8']) && !empty($_POST['door9']) && !empty($_POST['door10']) && !empty($_POST['door11']) && !empty($_POST['door12']) && !empty($_POST['door13']) )
    $query = "INSERT INTO form_details1(firstname,secondname,location,designation,fileno,doa,doj,cardtype1,cardcolor,cardtype2,door1,door2,door3,door4,door5,door6,door7,door8,door9,door10,door11,door12,door13) VALUES('$firstname','$secondname','$location','$designation','$fileno','$doa','$doj','$cardtype1',$cardcolor,'$cardtype2','$door1','$door2','$door3','$door4','$door5','$door6','$door7','$door8','$door9','$door10','$door11','$door12')"; //query
    if(mysqli_query($connect,$query)){ //check query executed or not
        echo 'inserted' . '<br>' ;
        echo "problem occur".mysqli_error($connect);
   echo "form values are required";
Watch Question

Most Valuable Expert 2011
Author of the Year 2014

Please use the code snippet feature when you post code here at E-E, thanks.  You can click the word "CODE" in the comment formatting bar and paste your code in between the tags.  This gives us line numbers and a unispace font making it easier to read and discuss the code.
Most Valuable Expert 2011
Author of the Year 2014

Suggest you simplify the problem and reduce it to something we can all work with.  Please, please, please post your test data!  Then when we have the simplified version working, we can build back up from there to the full application.


Getting Started
John TsioumprisSoftware & Systems Engineer
Distinguished Expert 2019

Have your run the SQL Insert query with some static data to check if it works as it should....
Distinguished Expert 2019
Unlock this solution and get a sample of our free trial.
(No credit card required)
Most Valuable Expert 2011
Author of the Year 2014

mysqli_real_escape_string() requires the link identifier (connection id) as the first argument, and the input variable as the second argument.



Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.