Forums

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

Home Forums Back End PHP Email form: Won’t parse the users input data

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #31142
    zio4
    Member

    Still fairly new to PHP so please bare with me… My issue is as the subject reads and here is the PHP I used from Chris but altered. Any help is appreciated greatly!!!

    $EmailTo = “[email protected]”;
    $Subject = “Team Registration! Action Requested”;

    $TeamName = Trim(stripslashes($_POST));
    $ManagerName = Trim(stripslashes($_POST));
    $ManagerAddress = Trim(stripslashes($_POST));
    $EmailOne = Trim(stripslashes($_POST));
    $EmailTwo = Trim(stripslashes($_POST));
    $PhoneOne = Trim(stripslashes($_POST));
    $PhoneTwo = Trim(stripslashes($_POST));

    // validation
    $validationOK=true;
    if (!$validationOK) {
    print ““;
    exit;
    }

    // prepare email body text
    $Body = “”;
    $Body .= “TeamName: “;
    $Body .= $TeamName;
    $Body .= “n”;
    $Body .= “ManagerName: “;
    $Body .= $ManagerName;
    $Body .= “n”;
    $Body .= “ManagerAddress: “;
    $Body .= $ManagerAddress;
    $Body .= “n”;
    $Body .= “EmailOne: “;
    $Body .= $EmailOne;
    $Body .= “n”;
    $Body .= “EmailTwo: “;
    $Body .= $EmailTwo;
    $Body .= “n”;
    $Body .= “PhoneOne: “;
    $Body .= $PhoneOne;
    $Body .= “n”;
    $Body .= “PhoneTwo: “;
    $Body .= $PhoneTwo;
    $Body .= “n”;

    // send email
    $success = mail($EmailTo, $Subject, $Body, “From: <$EmailFrom>“);

    // redirect to success page
    if ($success){
    print ““;
    }
    else{
    print ““;
    }
    ?>

    #67752
    zio4
    Member

    I don’t receive anything in the email besides the label text in the form.

    #67754
    Bob
    Member

    Are you missing a quotation mark there maybe?
    Shouldn’t:

    $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

    be:

    $success = mail("$EmailTo, $Subject, $Body, "From: <$EmailFrom>");

    So an added quotation mark before $EmailTo.

    #67760
    zio4
    Member

    I don’t believe so… the quotation marks in the line contain —-> From: <$EmailFrom>“); <----

    #67689
    Bob
    Member

    It seems you’re right zio4, I read that wrong. The quotation marks are fine indeed.

    However, are you actually even sending the form? I don’t think you are.
    To me, it looks like you’re only creating a variable called $success, and give it the value of mail($EmailTo, $Subject, $Body, “From: <$EmailFrom>“)

    Shouldn’t you after that actually ‘use’ the variable and thus mail the form? Or can’t you just mail(…) instead of making it a variable?

    Last, on your line with if ($success){, shouldn’t you be comparing that to something, like if ($success==true){?

    EDIT: Ok nevermind, I just saw this is how Chris has coded it so it should be fine.

    #67622
    zio4
    Member

    Thanks for the effort Bob!

    Here’s the code again for anyone else… I noticed a few things weren’t showing in the original post.




    $EmailFrom = "Nolte Classic";
    $EmailTo = "[email protected]";
    $Subject = "Registration";
    $TeamName = Trim(stripslashes($_POST));
    $ManagerName = Trim(stripslashes($_POST));
    $ManagerAddress = Trim(stripslashes($_POST));
    $EmailOne = Trim(stripslashes($_POST));
    $EmailTwo = Trim(stripslashes($_POST));
    $PhoneOne = Trim(stripslashes($_POST));
    $PhoneTwo = Trim(stripslashes($_POST));

    // validation
    $validationOK=true;
    if (!$validationOK) {
    print "";
    exit;
    }

    // prepare email body text
    $Body = "";
    $Body .= "TeamName: ";
    $Body .= $TeamName;
    $Body .= "n";
    $Body .= "ManagerName: ";
    $Body .= $ManagerName;
    $Body .= "n";
    $Body .= "ManagerAddress: ";
    $Body .= $ManagerAddress;
    $Body .= "n";
    $Body .= "EmailOne: ";
    $Body .= $EmailOne;
    $Body .= "n";
    $Body .= "EmailTwo: ";
    $Body .= $EmailTwo;
    $Body .= "n";
    $Body .= "PhoneOne: ";
    $Body .= $PhoneOne;
    $Body .= "n";
    $Body .= "PhoneTwo: ";
    $Body .= $PhoneTwo;
    $Body .= "n";


    // send email
    $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

    // redirect to success page
    if ($success){
    print "";
    }
    else{
    print "";
    }
    ?>

    #67658
    TT_Mark
    Member

    Trying dumping out your $_POST variable with

    var_dump($_POST);

    If it’s empty, then it’s your form..if its not empty, its the PHP.

    My guesses are
    a) You’ve given the form the wrong method i.e. GET
    b) You’ve not named the fields correctly
    c) Can you actually use trim() with a capital T??

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