PHP passing data from html form

Soldato
Joined
18 Oct 2002
Posts
9,213
Im coding a simple questionnaire, I want the data to be passed from the form to my email address. Easiest way seems to be with PHP following a tutorial such as this: http://www.thesitewizard.com/archive/feedbackphp.shtml

I have 17 questions made up of text boxes, radio buttons and check boxes. I can get the questionnaire to work as it should do when there is 1 or 2 fields, however when any great deal or added I get the following error:

Warning: mail() expects at most 5 parameters,

Is the above tutorial not the best way of doing what im trying to achieve?
 
The mail() function takes the following parameters:

mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]] )

The parameters in square brackets are optional.

It sounds like you're trying to do something like

Code:
mail("[email protected]", "Questionnaire Results", $answer1, $answer2, $answer3, $answer4)

What you need to do is concat (combine) all the answers into 1 string you can send as the message part of the email.

Try something like:

Code:
$emailTo = "[email protected]";
$subject = "Questionnaire Results";

$message = 'Answer 1: ' . $_POST['answer1'];
$message .= "\nAnswer 2: " . $_POST['answer2'];
$message .= "\nAnswer 3: " . $_POST['answer3'];
$message .= "\nAnswer 4: " . $_POST['answer4'];
$message .= "\nAnswer 5: " . $_POST['answer5'];
// etc...

mail($emailTo, $subject, $message);
 
Im confused as to why I should do this. My questionnaire does not contain an email address field, its just made up of tick boxes, radio buttons and a couple of text fields. I do not collect any information on the individual, just their opinions on various subjects etc. Unless I have totally missed the point (feel free to correct me) why is the validation relavent?
 
Back
Top Bottom