Add a record through the html form

Add a record through the html form

Hi, im trying to add a record through the html form with using curl, i read all guides, but it doesnt work
here is the code: 
  1. if(isset($_POST['button']) && $_SERVER['REQUEST_METHOD'] == "POST")
  2. {


  3. $message = strip_tags($_POST['message']);
  4. $_SESSION['message1'] = $message;
  5. $fname = ucwords($_POST['first_name']);
  6. $_SESSION['fname'] = $fname;
  7. $lname = ucwords($_POST['last_name']);
  8. $_SESSION['lname'] = $lname;
  9. $companyname = ucwords($_POST['company']);
  10. $_SESSION['companyname'] = $companyname;
  11. $address = ucwords($_POST['home_address']);
  12. $_SESSION['address1'] = $address;
  13. $address2 = ucwords($_POST['home_extended_address']);
  14. $_SESSION['address2'] = $address2;
  15. $city = ucwords($_POST['home_city']);
  16. $_SESSION['city'] = $city;
  17. $state = ucwords($_POST['home_state']);
  18. $_SESSION['state'] = $state;
  19. $zipcode = $_POST['home_postal_code'];
  20. $_SESSION['zipcode'] = $zipcode;
  21. $country = $_POST['home_country'];
  22. $_SESSION['country1'] = $country;
  23. $cell = $_POST['cell_tel'];
  24. $_SESSION['cell'] = $cell;
  25. $phone = $_POST['home_tel'];
  26. $_SESSION['phone'] = $phone;
  27. $fax = $_POST['fax_tel'];
  28. $_SESSION['fax'] = $fax;
  29. $email = $_POST['email1'];
  30. $_SESSION['email'] = $email;

  31.   $ch = curl_init();
  32.   curl_setopt($ch, CURLOPT_URL, "https://accounts.zoho.com/login?servicename=ZohoCreator&FROM_AGENT=true&LOGIN_ID=login&PASSWORD=password");
  33.   curl_setopt($ch, CURLOPT_RETURNTRANSFER , true);
  34.   $result = curl_exec($ch);
  35.  

  36.   $postfields = array(
  37.     "DATE_field" => date("m-d-y"),
  38.     "FIRST_NAME" => $_POST['first_name'],
  39.     "LAST_NAME" => $_POST['last_name'],
  40.     "COMPANY" => $_POST['company'],
  41.     "ADDRESS" => $_POST['home_address'],
  42.     "CITY" => $_POST['home_city'],
  43. "STATE" => $_POST['home_state'],
  44. "ZIP" => $_POST['home_postal_code'],
  45. "COUNTRY" => $_POST['home_country'],
  46. "CELL" => $_POST['cell_tel'],
  47. "PHONE" => $_POST['home_tel'],
  48. "FAX" => $_POST['fax_tel'],
  49. "EMAIL" => $_POST['email1'],
  50. "JOB_DESCRIPTION" => $_POST['message']);
  51.   $postfields['apikey'] = "apikeynumber";
  52.   $postfields['ticket'] = "fc01bae90522980e6ca95d6af459c74f";
  53.     
  54.   
  55.   $ch = curl_init();
  56.   curl_setopt($ch, CURLOPT_URL, "http://creator.zoho.com/api/csv/leads-database/LEADS_DATABASE_Form/add/"); 
  57.   curl_setopt($ch, CURLOPT_POST, true);
  58.   curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
  59.   $result = curl_exec($ch);
  60.   echo $result;
   
  
  session_destroy();

Any help would be highly appreciated