<form method="post" action="">
<div class="form-row">
<div class="col-12 col-md-9 mb-2 mb-md-0">
<input type="text" class="form-control form-control-lg" name="firstname" placeholder="Enter your Name">
</div>
<div class="col-12 col-md-9 mb-2 mb-md-0">
<input type="email" class="form-control form-control-lg" name="emailval" placeholder="Enter your email...">
</div>
<div class="col-12 col-md-3">
<button type="submit" name="submit" class="btn btn-block btn-lg btn-primary">Sign up!</button>
</div>
</div>
</form>
<?php
error_reporting(0);
$name2=$_REQUEST['firstname'];
$email2=$_REQUEST['emailval'];
if (isset($_POST['submit'])){
$arr = array(
'fields' => array(
array(
'name' => 'email',
'value' => $email2
),
array(
'name' => 'firstname',
'value' => $name2
)
)
);
$post_json = json_encode($arr);
$endpoint = 'https://api.hsforms.com/submissions/v3/integration/submit/portalid/formguid';
$ch = @curl_init();
@curl_setopt($ch, CURLOPT_POST, true);
@curl_setopt($ch, CURLOPT_POSTFIELDS, $post_json);
@curl_setopt($ch, CURLOPT_URL, $endpoint);
@curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = @curl_exec($ch);
$status_code = @curl_getinfo($ch, CURLINFO_HTTP_CODE);
$curl_errors = curl_error($ch);
@curl_close($ch);
if($response == '{"inlineMessage":"Thanks for submitting the form."}'){
echo "Form Submit Successfully";
}
}
?>
No comments:
Post a Comment