PHP Pear - adding variables to $body message

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

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

*N

2条回答
  •  时光取名叫无心
    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;
    ...
    

提交回复
热议问题