Jump to content

[SOLVED] Contact Form - Input fax from multiple fields


spocek

Recommended Posts

Hi Everyone,

 

I am trying to add 4 fields to my form for a fax number which once passed to my mailform code would be joined in a single string and e-mailed to [email protected].

 

How could I do that?

 

HTML form code file:

 

<td class="style9">Fax Number </td>

    <td class="style9"><input type="text" name="Fax" size="1" maxlength="1">

       

      <input type="text" name="Fax" size="3" maxlength="3">

       

      <input type="text" name="Fax" size="3" maxlength="3">

       

      <input type="text" name="Fax" size="4" maxlength="4"></td>

 

This code also needs to pass "@greenfax.com"

 

PHP mail code file:

 

$EmailTo = Trim(stripslashes($_POST['Fax']));

 

Thank you on your help.

 

dont know what you really mean but i guess you mean the concatenator

 

it goes this way

$variable = "hello im teng";

$variable .= $_POST['ur field name here'];

 

now you have

hello im teng the value of the form

 

or you can have this way

echo "hello im teng".$_POST['ur field name here'];

 

is that

 

Ok, you don't undestand what I am trying to do here.  I have a simple mail form.  Right now I have to type in the recipient e-mail which is a fax service.  The form works and I can type in any e-mail address and it will send the contents to that e-maila address.  The form needs to send data to a fax server.  For example: [email protected].  I would like to break down the digit field into four fields:

 

1 digit - 3 digits - 3 digits - 4 digits. 

 

I would also like that the string "@greenfax.com" automatically joins the digits in the mail form code. 

 

Thus, you end up with [email protected] being the value of $EmailTo variable which in turn will send the contents of the entire form to [email protected] or whatever fax number I specify.  The fax number will always end with "@greenfax.com".

 

PHP mail code file:

 

$EmailTo = Trim(stripslashes($_POST['Fax']));

 

Please see my attachments.  Rename them from .txt to .php...

 

Once again, thank you all.

 

[attachment deleted by admin]

Ok, you don't undestand what I am trying to do here.

 

Actually I do.  You showed a form with four fields. Each of them was NAMEd 'Fax'.  When you have identically NAMEd fields, the second overwrites the first, the third overwrites the second and you end up with only one value (after all there's only one $_POST['Fax']).

 

Rename the fields so they're all different and concatenate the FOUR resultant values.  Or you can name each of the fax fields Fax[] nothing in the brackets.  Then you'll get 4 different POSTed values all in a nice litle array named Fax and you can aggregate them, implode them, concatenate them.

 

FYI, the concatentation operator is a dot

 

$thisnthat = $this. $that

Thanks on your reply.  I understand your logic but since I am not great at PHP - how would I aggregate them?  I think that a possible solution would be this:

 

HTML form code file:

 

<td class="style9">Fax Number </td>

    <td class="style9"><input type="text" name="Fax1" size="1" maxlength="1">

       

      <input type="text" name="Fax2" size="3" maxlength="3">

       

      <input type="text" name="Fax3" size="3" maxlength="3">

       

      <input type="text" name="Fax4" size="4" maxlength="4"></td>

 

This code also needs to pass "@greenfax.com"

 

PHP mail code file:

 

$EmailTo = Trim(stripslashes($_POST['Fax1' . 'Fax2' . 'Fax3' . 'Fax4' . '"@greenfax.com']));

 

Please see the two files that I have attached in my earlier reply.  Thanks.

I tested my "solution" but it generates an error message.  There has to be a solution - when you have phone/credit card numbers in a form (multiple input fields) - how does that data get sent as a single string...  Please make edits to my two files (attached in one of my earlier posts) - I am so lost  ???

 

Thanks

I get a parse error.   :-[

 

Would the following edits to your code work?

 

pr_form.php:

 

  <td class="style9">Fax Number </td>

    <td class="style9">

      <input name="fax1" type="text" id="fax1" size="1" maxlength="1">

      <input name="fax2" type="text" id="fax2" size="3" maxlength="3">

      <input name="fax3" type="text" id="fax3" size="3" maxlength="3">

      <input name="fax4" type="text" id="fax4" size="4" maxlength="4">

   </td>

 

mail_pr_form.php:

 

$fax1 = Trim(stripslashes($_POST['fax1']));

$fax2 = Trim(stripslashes($_POST['fax2']));

$fax3 = Trim(stripslashes($_POST['fax3']));

$fax4 = Trim(stripslashes($_POST['fax4']));

 

$EmailTo = $fax1. $fax2. $fax3. $fax4. "@greenfax.com";

 

Is there suppose to be an additional space between those periods?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.