Hello guys,
I have a form on our websites that is collecting leads via Lead capture.
Because I am noob I need your help.
I have a form with code:
and I have a php script (send.php) to send the request with code:
Everything is working as expected but I would love to have one more field passed to our system with hardcoded value and without the field being present in the form. Could you please tell me how to adjust the send.php script to be able to achieve my needs?
I thought little adjustment of the $params in send.php will do the magic, but I am not able to pass hardcoded value to the field "descriptionNew"
I tried this syntax where I was trying to send string "TestPoznamka" to the field descriptionNew, but the Lead was created with empty description:
Thanks a lot.
I have a form on our websites that is collecting leads via Lead capture.
Because I am noob I need your help.
I have a form with code:
Code:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Cenová nabídka</title> <!-- CSS only --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous"> <link href="style.css" rel="stylesheet"> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@100&display=swap" rel="stylesheet"> </head> <body> <main> <div class="container py-4"> <header class="pb-3 mb-4 border-bottom"> </header> <form method="post" action="./send.php"> <div class="p-5 mb-4 rounded-3 form"> <div class="mb-3"> <label for="firstName" class="form-label">Křestní jméno*</label> <input type="text" class="form-control" id="firstName" name="firstName" placeholder="Jan"> </div> <div class="mb-3"> <label for="lastName" class="form-label">Příjmení*</label> <input type="text" class="form-control" id="lastName" name="lastName" placeholder="Novák"> </div> <div class="mb-3"> <label for="emailAddress" class="form-label">Emailová adresa*</label> <input type="email" class="form-control" id="emailAddress" name="emailAddress" placeholder="name@example.eu"> </div> <div class="mb-3"> <label for="phoneNumber" class="form-label">Telefonní číslo*</label> <input type="text" class="form-control" id="phoneNumber" name="phoneNumber" placeholder="+420702123456"> </div> <div class="mb-3"> <label for="addressState" class="form-label">Kraj</label> <select class="form-control" id="addressState" name="addressState" placeholder="Jihomoravský kraj"> <option value="Hlavní město Praha">Hlavní město Praha</option> <option value="Jihočeský kraj">Jihočeský kraj</option> <option value="Jihomoravský kraj">Jihomoravský kraj</option> <option value="Karlovarský kraj">Karlovarský kraj</option> <option value="Kraj Vysočina">Kraj Vysočina</option> <option value="Královéhradecký kraj">Královéhradecký kraj</option> <option value="Liberecký kraj">Liberecký kraj</option> <option value="Moravskoslezský kraj">Moravskoslezský kraj</option> <option value="Olomoucký kraj">Olomoucký kraj</option> <option value="Pardubický kraj">Pardubický kraj</option> <option value="Plzeňský kraj">Plzeňský kraj</option> <option value="Středočeský kraj">Středočeský kraj</option> <option value="Ústecký kraj">Ústecký kraj</option> <option value="Zlínský kraj">Zlínský kraj</option> </select> </div> <button type="submit" class="button btn-primary">Odeslat formulář</button> </div> </form> </div> </main> </body> <!-- JavaScript Bundle with Popper --> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-U1DAWAznBHeqEIlVSCgzq+c9gqGAJn5c/t99JyeKa9xxaYpSvHU5awsuZVVFIhvj" crossorigin="anonymous"></script> </html>
Code:
<?php if(empty($_POST['emailAddress']) || empty($_POST['firstName']) || empty($_POST['lastName'])) { echo "Prosím vyplňte všechny povinné pole"; die; } $params = array( 'emailAddress' => $_POST['emailAddress'], 'firstName' => $_POST['firstName'], 'lastName' => $_POST['lastName'], 'addressState' => $_POST['addressState'], 'phoneNumber' => $_POST['phoneNumber'], 'descriptionNew' => $_POST['TestPoznamka'] ); $thankYouURL = "https://fotovoltaika.esmero.eu/dekovaci-stranka"; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://OURCRMURL.eu/api/v1/LeadCapture/cab25709d6c5c12c3b800185241cea26", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => json_encode($params), CURLOPT_HTTPHEADER => array( "Cache-Control: no-cache", "Content-Type: application/json" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); header("Location: $thankYouURL") ?>
I thought little adjustment of the $params in send.php will do the magic, but I am not able to pass hardcoded value to the field "descriptionNew"
I tried this syntax where I was trying to send string "TestPoznamka" to the field descriptionNew, but the Lead was created with empty description:
Code:
$params = array( 'emailAddress' => $_POST['emailAddress'], 'firstName' => $_POST['firstName'], 'lastName' => $_POST['lastName'], 'addressState' => $_POST['addressState'], 'phoneNumber' => $_POST['phoneNumber'], 'descriptionNew' => $_POST['TestPoznamka'] );
Comment