phpretard Posted February 9, 2008 Share Posted February 9, 2008 Is there a way to capture all of the posted fields in a form with one string?. This as opposed to typing -- $_POST['bunches'] -- many many times? Link to comment https://forums.phpfreaks.com/topic/90200-large-form/ Share on other sites More sharing options...
kenrbnsn Posted February 9, 2008 Share Posted February 9, 2008 You could do <?php $fields = implode('~',$_POST); ?> which would put all responses into the string $fields separated by the "~" character, but you would loose the field names. If you tell us what you are trying to do, we might be able to help you. Ken Link to comment https://forums.phpfreaks.com/topic/90200-large-form/#findComment-462531 Share on other sites More sharing options...
phpretard Posted February 9, 2008 Author Share Posted February 9, 2008 I am simple trying to submit a form and email the information from it. I can do that no sweat. I just know there must be a better way then to type $_post['info'] for every field. I have about 40 fields. This isn't detramental, I just would like to know if there is a better way. Thanks a million! -Anthony Link to comment https://forums.phpfreaks.com/topic/90200-large-form/#findComment-462621 Share on other sites More sharing options...
kenrbnsn Posted February 9, 2008 Share Posted February 9, 2008 The easiest way to get information into an email message is: <?php $to = '[email protected]'; $subject = 'Form filled in'; $headers = 'From: [email protected]'; $body = print_r($_POST,true); mail($to, $subject, $body, $headers); ?> Ken Link to comment https://forums.phpfreaks.com/topic/90200-large-form/#findComment-462638 Share on other sites More sharing options...
phpretard Posted February 10, 2008 Author Share Posted February 10, 2008 That worked great. Any pointers on how to manipulate this " [c1name] => Anthony Jones " c1name should be "Customer 1 Name = Anthony Jones". Link to comment https://forums.phpfreaks.com/topic/90200-large-form/#findComment-463286 Share on other sites More sharing options...
kenrbnsn Posted February 10, 2008 Share Posted February 10, 2008 What the print_r() gives you is the raw information that comes from your form. The string between the "[]" is the name you've put in the "<input>" line of the form. If you want to make it more meaningful you will have to do some more work. Create an array with the correspondence between the field names and what you want. Something like: <?php $flds = array('fld1' => 'field one','c1name'=>'Customer 1 Name','fld3'=>'Field Three'); $bdy = array(); foreach ($flds as $nam => $val) $bdy[] = $val . ' = ' . $_POST[$fld]; $body = implode("\n",$bdy); $to = '[email protected]'; $subject = 'Form filled in'; $headers = 'From: [email protected]'; mail($to, $subject, $body, $headers); ?> Ken Link to comment https://forums.phpfreaks.com/topic/90200-large-form/#findComment-463290 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.