Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JasvinderSingh1/ed53202da806068f674a511fa7c65a34 to your computer and use it in GitHub Desktop.
Save JasvinderSingh1/ed53202da806068f674a511fa7c65a34 to your computer and use it in GitHub Desktop.
Adobe Acrobat Code
API code:
<?php
$hostname = "localhost";
$username = "id21145254_devjas";
$password = "Peter@007";
$database = "id21145254_devjas";
$mysqli = new mysqli($hostname, $username, $password, $database);
if ($mysqli->connect_error) {
die("Connection failed: " . $mysqli->connect_error);
}
echo "Connected successfully!";
// Check if the request method is POST
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$fileContents= file_get_contents('php://input');
$fileContents = str_replace(array("\n", "\r", "\t"), '', $fileContents);
$fileContents = trim(str_replace('"', "'", $fileContents));
$simpleXml = simplexml_load_string($fileContents);
$data1 = json_decode(json_encode($simpleXml,JSON_PRETTY_PRINT), true);
for($i = 0; $i<count($data1['fields']['field']); $i++){
$submittedData[$data1['fields']['field'][$i]['@attributes']['name']] = $data1['fields']['field'][$i]['value'];
}
echo 3; print_r($submittedData);
$applicant_title = $submittedData['title1'];
$applicant_f_name = $submittedData['fname1'];
$applicant_m_name = $submittedData['mname1'];
$applicant_l_name = $submittedData['lname1'];
$query = "INSERT INTO clients (applicant_title, applicant_f_name, applicant_m_name, applicant_l_name) VALUES (?, ?, ?, ?)";
$stmt = $mysqli->prepare($query);
$stmt->bind_param("ssss", $applicant_title, $applicant_f_name, $applicant_m_name, $applicant_l_name);
if ($stmt->execute()) {
echo "Data inserted successfully!";
} else {
echo "Error: " . $stmt->error;
}
// Close the statement and connection
$stmt->close();
$mysqli->close();
// Return a response
$response = array('status' => 'success', 'message' => 'Data received and processed successfully');
echo json_encode($response);
}
?>
Adobe code:
var aSubmitFields = new Array( "title1" ,"fname1","mname1","lname1");
var x1=this.getField("title1").value;
var x2=this.getField("fname1").value;
var x3=this.getField("mname1").value;
var x4=this.getField("lname1").value;
if(x1!="" && x2!="" && x3!="" && x4!="")
{
app.alert("aSubmitFields:"+ aSubmitFields);
var response = this.submitForm({
cURL: "https://dev-jas.000webhostapp.com/",
aFields: aSubmitFields,
cSubmitAs: "XFDF"
});
app.alert("Data Saved Successfully",3);
}
else
{
app.alert("Please fill the required fields before submit");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment