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:
- if(isset($_POST['button']) && $_SERVER['REQUEST_METHOD'] == "POST")
- {
- $message = strip_tags($_POST['message']);
- $_SESSION['message1'] = $message;
- $fname = ucwords($_POST['first_name']);
- $_SESSION['fname'] = $fname;
- $lname = ucwords($_POST['last_name']);
- $_SESSION['lname'] = $lname;
- $companyname = ucwords($_POST['company']);
- $_SESSION['companyname'] = $companyname;
- $address = ucwords($_POST['home_address']);
- $_SESSION['address1'] = $address;
- $address2 = ucwords($_POST['home_extended_address']);
- $_SESSION['address2'] = $address2;
- $city = ucwords($_POST['home_city']);
- $_SESSION['city'] = $city;
- $state = ucwords($_POST['home_state']);
- $_SESSION['state'] = $state;
- $zipcode = $_POST['home_postal_code'];
- $_SESSION['zipcode'] = $zipcode;
- $country = $_POST['home_country'];
- $_SESSION['country1'] = $country;
- $cell = $_POST['cell_tel'];
- $_SESSION['cell'] = $cell;
- $phone = $_POST['home_tel'];
- $_SESSION['phone'] = $phone;
- $fax = $_POST['fax_tel'];
- $_SESSION['fax'] = $fax;
- $email = $_POST['email1'];
- $_SESSION['email'] = $email;
-
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, "https://accounts.zoho.com/login?servicename=ZohoCreator&FROM_AGENT=true&LOGIN_ID=login&PASSWORD=password");
- curl_setopt($ch, CURLOPT_RETURNTRANSFER , true);
- $result = curl_exec($ch);
-
- $postfields = array(
- "DATE_field" => date("m-d-y"),
- "FIRST_NAME" => $_POST['first_name'],
- "LAST_NAME" => $_POST['last_name'],
- "COMPANY" => $_POST['company'],
- "ADDRESS" => $_POST['home_address'],
- "CITY" => $_POST['home_city'],
- "STATE" => $_POST['home_state'],
- "ZIP" => $_POST['home_postal_code'],
- "COUNTRY" => $_POST['home_country'],
- "CELL" => $_POST['cell_tel'],
- "PHONE" => $_POST['home_tel'],
- "FAX" => $_POST['fax_tel'],
- "EMAIL" => $_POST['email1'],
- "JOB_DESCRIPTION" => $_POST['message']);
- $postfields['apikey'] = "apikeynumber";
- $postfields['ticket'] = "fc01bae90522980e6ca95d6af459c74f";
-
-
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, "http://creator.zoho.com/api/csv/leads-database/LEADS_DATABASE_Form/add/");
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
- $result = curl_exec($ch);
- echo $result;
session_destroy();
Any help would be highly appreciated