The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Sending HTTP Parameters Through Email *Important*

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #30963

    Hello All,

    *Edited Title*
    If anyone needs more information on the issue, please let me know. I need to get over this hurdle as soon as I can.

    I have been working on a way to get this to work for the past week or so.
    I need to grab the parameters in the URL and list them in an array and display that array in the message of the email. The issue I am having is finding a way to properly display the array in the body of the email.

    Example 1:
    In this example I just tried taking the parameters from the URL and assigning them to the message variable. All I get in the email if the email goes through is the first line with the variable omitted.

    $responseCode = $_POST;
    $responseMessage = $_POST;
    $customerCode= htmlentities($_POST);
    $trnOrderNumber = $_POST;
    $cardType = $_POST;
    $cardNumber = $_POST;
    $ref1 = $_POST;
    $ref2 = $_POST;
    $ref3 = $_POST;
    $ref4 = $_POST;
    $ref5 = $_POST;

    if($responseCode = 1)
    $approved = "Success";
    $approved = "Failure " . $responseCode;

    $to = "[email protected]";
    $subject = "SPP Response - $approved";
    $message = "Response Code = $responseCode
    $message .= "Response Message = $responseMessage
    $message .= "Customer Code = $customerCode
    $message .= "Order Number = $trnOrderNumber
    $message .= "Card Type = $cardType
    $message .= "Card Number = $cardNumber
    $message .= "Ref1 = $ref1
    $message .= "Ref2 = $ref2
    $message .= "Ref3 = $ref3
    $message .= "Ref4 = $ref4
    $message .= "Ref5 = $ref5
    $headers = "From: [email protected] rn";
    $headers .= "Content-type: text/htmlrn";

    mail($to, $subject, $message, $headers);


    Example 2:
    I built an array from the URL parameters and tested them by printing them on screen when I access the page, however I cannot find any way of displaying the array in the body of the email. If I use a print function then it just displays the array on the screen, and shows “array” as the value in the body of the email.

    $request = array(
    "trnApproved" => $_REQUEST,
    "trnId" => $_REQUEST,
    "adjTrnId" => $_REQUEST,
    "messageId" => $_REQUEST,
    "messageText" => $_REQUEST,
    "authCode" => $_REQUEST,
    "trnAmount" => $_REQUEST,
    "trnDate" => $_REQUEST,
    "trnOrderNumber" => $_REQUEST,
    "trnCustomerName" => $_REQUEST,
    "trnEmailAddress" => $_REQUEST,
    "trnPhoneNumber" => $_REQUEST,
    "avsProcessed" => $_REQUEST,
    "avsResult" => $_REQUEST,
    "avsAddrMatch" => $_REQUEST,
    "avsPostalMatch" => $_REQUEST,
    "avsMessage" => $_REQUEST,
    "cvdId" => $_REQUEST,
    "trnType" => $_REQUEST,
    "paymentMethod" => $_REQUEST,

    if($request = 1){
    $approved = "Approved";} else {
    $approved = "Declined";

    $url = 'http' . ((!empty($_SERVER)) ? 's' : '') . '://'.$_SERVER.$_SERVER;

    $to = "[email protected]";
    $subject = "PHP Response Notification - $approved";
    $message = "$url";
    $header = "From: [email protected]";

    mail( $to, $subject, $message, $header);


    Be kind, I am a PHP amateur :P.


    At first I thought that the variables set in the first example would only be available within the ‘if’ statement, reverting to nothing upon completion of the ‘if’, try declaring all of the variables as ‘0’ before starting your ‘if’ statements.

    responseCode = responseMessage = (all other variables) = 0;

    Worth a shot right?


    Sorry but I am not following you.
    What will assigning all of the variables to 0 accomplish?

    Currently the example checks if the parameter is set, and if it is set then it assigns the parameter to a variable of the same name. The if statement executes and the variable is assigned. If I assign the variables to 0, then won’t they just simply equal nothing?


    I’m probably miles off as my knowledge of PHP is only from recreation. Does the variable inside the ‘if’ statement exist outside of the ‘if’ or is it forgotten.

    Variables declared in a class, are private to the class – so not accessible to any other class. I don’t know if the same applies to ‘if’s.

    Also it shouldn’t affect your code, because if any of the ‘$POST[]’ have data it will over write the 0.

    Have you tried my approach to see if it helps? – Couldn’t make it any worse.

    Sorry if I am not moving you forward.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Back End’ is closed to new topics and replies.