Re: Mailing all the elements of a form

From: Date: Sun, 07 Jul 2002 20:37:07 +0000
Subject: Re: Mailing all the elements of a form
Groups: php.general 
Request: Send a blank email to php-general+get-105968@lists.php.net to get a copy of this message
Hi Jeremy You might try the following: 1. set your form elements up so each input can be accessible as part of an associative array e.g. <FORM ...> <input type="text" name="input_array[forename]" value=""> <input type="text" name="input_array[lastname]" value=""> </FORM> 2. create a trusted fields array in your mailing script: $trusted_fields = array("forename", "surname"); order this array in the order you wish the form items to be mailed, e.g. forename, surname, address etc. 3. loop through each item in the trusted fields array and get the value of the corresponding field out of the input_array, build the body of your email and send as required - as you go through each field you can do form validation, and format the output as required, for example: foreach ($trusted_fields as $trusted_field) { if (!empty($input_array[$trusted_field])) $body .= $trusted_fields[$trusted_field] . ":" . $input_array [$trusted_field] . "\n"; } This in theory will build the body as field: field_value\n.. for each field in the the trusted_fields array that is not empty. code untested - but concept should work. Rgds John ---- Original Message ---- From: Jeremy Bowen Date: Sun 7/7/02 6:31 To: php-general@lists.php.net Subject: [PHP] Mailing all the elements of a form Hey, I have looked in PHP manual but I cannot seem to find what I am looking for. I have a very large form that I need to be able to mail. I just don't want to have to code all of the field into my mail() function. Thanks, Jeremy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#105968) next »