Jump to content

Large Form


phpretard

Recommended Posts

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
Share on other sites

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
Share on other sites

The easiest way to get information into an email message is:

<?php
$to = 'your.email.address@here.com';
$subject = 'Form filled in';
$headers = 'From: your.email@address.here';
$body = print_r($_POST,true);
mail($to, $subject, $body, $headers);
?>

 

Ken

Link to comment
Share on other sites

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 = 'your.email.address@here.com';
$subject = 'Form filled in';
$headers = 'From: your.email@address.here';
mail($to, $subject, $body, $headers);
?>

 

Ken

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.