Jump to content

Recommended Posts

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? 

Link to comment
https://forums.phpfreaks.com/topic/309314-curl-noob-here/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.