0

I have a really simple form of which I need to show the value posted in 'Client_custom_50', and I have tried multiple ways but I can't seem to show the results on the 'landing-thank-you.php' page, I have tried: var_dump($_REQUEST); and I receive this:

array(12) { ["Prefs_dontMatchOnClientName"]=> string(0) "" 
            ["Client_name"]=> string(0) "" 
            ["Contact_name"]=> string(4) "test" 
            ["Contact_email"]=> string(13) "test@test.com" 
            ["Contact_phone"]=> string(14) "00000000000000" 
            ["Client_custom_49"]=> string(0) "" 
            ["Client_custom_50"]=> string(17) "La Cala Hill Club" 
            ["Client_custom_48"]=> string(0) "" 
            ["Client_custom_55"]=> string(0) "" 
            ["formCid"]=> string(4) "6784" 
            ["formId"]=> string(37) "6784ud015dc078c474200ba24f18aa6588afc" 
            ["validation"]=> string(0) "" 
          } 

I have tried echo $_REQUEST['Client_custom_50']; perhaps I am missing something really obvious.

My form goes into our CRM system using a url of: then redirects to the thank-you page, if i tell the action to go to direct to the 'landing-thank-you.php' instead of passing through the CRM everything is fine, so how can I get it to keep the CRM action, which will then go to the thank-you (and also show my results)

index.php HTML:

<!--<form action="https://power.upsales.com/api/external/formSubmit" method="POST" class="upsale-form">-->
        <form action="landing-thank-you.php" method="post" class="upsale-form">
            <input type="hidden" class="form-control" name="Prefs.dontMatchOnClientName" style="display: none;" />
            <input type="hidden" class="form-control" name="Client.name" style="display: none;" />
            <div class="control-group">
                <input type="text" class="form-control required" name="Contact.name" placeholder="Name" required />
            </div>
            <div class="control-group">
                <input type="email" class="form-control required" placeholder="Email" name="Contact.email" required />
            </div>
            <div class="control-group">               
                <input type="text" class="form-control required" placeholder="Phone" name="Contact.phone" required />
            </div>

            <input type="hidden" class="form-control origin" name="Client.custom_49" />
            <input type="hidden" class="form-control propertyRef" id="hiddenValue" name="Client.custom_50" value="La Cala Hill Club" />
            <input type="hidden" class="form-control remarketing" name="Client.custom_48" />
            <input type="hidden" class="form-control keyword" name="Client.custom_55" />

            <input type="hidden" name="formCid" value="6784" />
            <input type="hidden" name="formId" value="6784ud015dc078c474200ba24f18aa6588afc" />
            <input type="hidden" name="validation" value="" />
            <input type="submit" value="Submit" id="submit" />
        </form>

thank-you page php:

//var_dump($_REQUEST);
        $property = $_REQUEST['Client_custom_50'];
        $propertyName = strtolower(str_replace(" ", "-", $property)); 

        $propertyDevName = $_REQUEST['Client_custom_50'];

        if ($_REQUEST['Client_custom_50'] == $propertyDevName) {
            echo "<a href='download/".$propertyName.".pdf'>Download PDF for ".$property."</a>";
        }
Graham Barnes
  • 235
  • 2
  • 6
  • 18

2 Answers2

1

The problem here is this

name="Client.custom_50"
            ^

and you're using

$_REQUEST['Client_custom_50']
                 ^

The name attribute has a dot for the input, and the $_REQUEST array has an underscore.

The same thing goes for some of your other inputs.

  • Both name attributes and $_REQUEST arrays must match.

Either you rename it to name="Client_custom_50" or rename your $_REQUEST array $_REQUEST['Client.custom_50']. Again, the same thing goes for all your inputs with the dots.

  • The choice is yours

Nota: The above was stricken out, as PHP replaces dots with underscores. I noticed this after testing and had remembered then that PHP does that automatically.

  • Sidenote: Some of your hidden inputs have no values.

Add error reporting to the top of your file(s) which will help find errors.

<?php 
error_reporting(E_ALL);
ini_set('display_errors', 1);

// rest of your code

Sidenote: Displaying errors should only be done in staging, and never production.


Footnotes:

Sidenote: Something is unclear though. Your action shows as action="landing-thank-you.php" yet you show in your question "thank-you page php". You probably meant "landing-thank-you.php".

  • Use a conditional isset() or !empty() for all your $_REQUESTs.

Nota:

If your CRM is going through more than 1 page, then your subsequent pages will lose all values.

You will need to use sessions for this.

Something to check also is to see if there isn't an invisible transformation happening, changing characters such as dots/underscores somewhere.

If this is cross-domain related, consult this Q&A on Stack on preserving session variables across different domains.

This may also prove to be useful:

Sidenote: Seeing this commmented out action="https://power.upsales.com/api/external/formSubmit" is also questionable. This looks to be the CRM you're going through.


Sessions example:

<?php 

session_start();

error_reporting(E_ALL);
ini_set('display_errors', 1);

    $property = $_REQUEST['Client_custom_50'];
    $propertyName = strtolower(str_replace(" ", "-", $property)); 

    $propertyDevName = $_REQUEST['Client_custom_50'];

    if ($_REQUEST['Client_custom_50'] == $propertyDevName) {
        echo "<a href='download/".$propertyName.".pdf'>Download PDF for ".$property."</a>";
    }

$_SESSION['var'] = $propertyDevName;

?>

<a href="landing_2.php">Check session</a>

landing_2.php

<?php 

session_start();

if(isset($_SESSION['var'])){

    echo $_SESSION['var'];

    $var2 = $_SESSION['var'];

    echo "<hr>";

    echo $var2;

}

...which echo'd "La Cala Hill Club" twice (and assigning a variable to it) while using your posted code.

  • Therefore a possible solution for you here, would be sessions.

If you're worried about sessions hijacking, read the following articles:

Community
  • 1
  • 1
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
  • 1
    In my opinion, @Fred-ii- _has hit the nail firmly on the head_ in the final **Nota:** part of his answer. If you traverse through one page to get to the second, your POST data will be received by the first script, but unless you do something in script1 to pass the $_POST data on to the second script, __probably in $_SESSION__ you will not get access to it in the second script – RiggsFolly Oct 27 '15 at 14:14
  • @RiggsFolly Plus, `action="https://power.upsales.com/api/external/formSubmit" method="POST"` being commented out like that; is a bit questionable. – Funk Forty Niner Oct 27 '15 at 14:20
-1

you dont have any 'Client_custom_50',you must have input value same as:

<input type="hidden" class="form-control remarketing" name="Client.custom_50" />
  • Thats what I initially thought however when I did the var_dump($_REQUEST); it showed Client_custom_50 and not Client.custom_50 but that still doesn't explain my conditional statement works but then when it goes to the CRM and then to the thankyou the request isn't found. I tried using Client.custom_50 but I had no luck either. – Graham Barnes Oct 27 '15 at 13:55
  • Something, either the browser or PHP, probably PHP, does an invisible conversion of dots to underscores in a field names to make it into a valid PHP variable name. Its better IMO to not rely on this and therefore **not use dots in an input field name** but it is not the reason for this issue. – RiggsFolly Oct 27 '15 at 14:21