Hi guys! Total noob here that needs a bit of help creating a form. I have gotten this piece of code and want people to optin with Name and email. Let me send the code first:
Request for PHP language:
<?php
$apiUrl = "https://udimi.com/api/affgen/addref";
$headers = [
"Content-Type: application/json",
"Auth: MY AUTH CODE HERE"
];
$referral = [
'fullname' => 'Referral Fullname',
'email' => 'refemail@domain.com'
];
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $apiUrl,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($referral),
CURLOPT_HTTPHEADER => $headers
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Success JSON response (HTTP status code: 200):
{"error": false}
Failed JSON response (HTTP status code: 200):
{"error": "Pass identity verification and earn a commission as Udimi affiliate."}
POST fields:
fullname: required, 2-25 chars, only English letters.
email: required
So I figured I need to create a html file with a simple form, so I created this:
<fieldset>
<legend>Form</legend>
<form action="test.php" method="post">
<label>Full Name: </label><input type="text" name="fullname" /><br />
<label>Email: </label><input type="text" name="email" /><br />
<input type="submit" name="submit" value="submit" />
</form>
</fieldset>
The problem is that I got it populate something when entering the form but the name was "Referral Fullname" as the code and the email was "refemail..." as the code. It did not grab my input.
Any pointers here? Should I approach it in another way?