-4

this php code is written at the end of of my file

 <?php

if(isset($_POST['submit']))
{
  $Jobtitle = $_POST['jobtitle'];
  $Firstname = $_POST['firstname'];
  $Lastname = $_POST['lastname'];
  $Name=$Firstname+$Lastname;
  $Sin = $_POST['sin'];
  $Phone = $_POST['phone'];
  $Email = $_POST['email'];
  $Address = $_POST['address'];
  $Postal = $_POST['postal'];
  $State = $_POST['state'];
  $Country = $_POST['country'];
  $Skill = $_POST['skill'];
  $Owntransport = $_POST['owntransport'];
  $ADate = $_POST['a-date'];
  $Workpermit = $_POST['workpermit'];
  $Daysavailable = $_POST['days-available'];
  $Strength = $_POST['strength'];
  $eFirstname = $_POST['efirstname'];
  $eLastname = $_POST['elastname'];
  $eName=$eFirstname+$eLastname;
  $ePhone = $_POST['ephone'];
  $query=" INSERT INTO `general`(`jobtitle`, `name`, `sin`, `pno`, `email`, `address`, `doc`, `skills`, `transport`, `avadate`, `authorize`, `days`, `strength`, `ename`, `ephone`) VALUES ('{$Jobtitle}','{$Name}','{$Sin}','{$Phone}','{$Email}','{$Address}','{$Postal}','{$State}','{$Country}','{$Skill}','{$Owntransport}','{$ADate}','{$Workpermit}','{$Daysavailable}','{$Strength}','{$eName}','{$ePhone}')";
 // $query = "INSERT INTO info (name,password,gender,hobby,phone no,dob,message) VALUES ('{$Name}','{$Password}','{$Gender}','{$Hobby}','{$Phone}','{$Dob}','{$Message}')";
  $result = mysql_query($query);
  if($result)
  {
    echo "data entered";
  }
  unset($_POST);
}
else{
  echo "error in entering data";
}

?>

this is the button tag

<button type="button" class="btn btn-primary"name="submit"value="submit" id="submit">Submit</button>

this is the form tag

<form method="post" id="contactform" action="#" role="form">

connection .php file giving me the connection to database but I am unable to store the data in databse it gives me the error that data is not entered

Asif Mehmood
  • 473
  • 3
  • 16

1 Answers1

1

Issue it that, you are using 15 columns and trying to update 17 values.

I think you missed state and postal columns.

Side Note:

Two more issues:

  1. Using mysql_* extension its deprecated and not available in PHP 7.
  2. Your code is open for SQL Injection.

Suggestion:

Use mysqli_* or PDO for point 1.

For debugging, always use PHP error_reprting active in your code.

devpro
  • 16,184
  • 3
  • 27
  • 38