PHP Pear - adding variables to $body message

前端 未结 2 1775
终归单人心
终归单人心 2021-01-28 18:46

This is my HTML form, which is inside a little box on my site.

*N

相关标签:
2条回答
  • 2021-01-28 18:54

    You have not mention where you have kept your php code file? Is it contact folder? and also look after the file location of Mail.php. This file must be under contact folder.

    0 讨论(0)
  • 2021-01-28 19:05

    In the code you posted, you attempted to set the value of $body on line 13, but did not set the value of $name until line 22. $name is null at the time you assign it to $body, so $body does not contain the values you are hoping for.

    To fix this problem, move the $body = ... line below the other assignments. Something like this:

    ...
    // Get form var's   
    $name = "Test"; //  I set $name to "Test" in the PHP and still the variable does not appear in the email.
    $destin = $_POST['destin'];
    $email = $_POST['Email'];
    $pfrom = $_POST['pfrom'];
    
    // Populate $body
    $body = $name . " wants to go to " . $destin . " from " . $pfrom;
    ...
    
    0 讨论(0)
提交回复
热议问题