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 faxnumber@greenfax.com.

 

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.

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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: 15641234567@greenfax.com.  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 15641234567@greenfax.com being the value of $EmailTo variable which in turn will send the contents of the entire form to 15641234567@greenfax.com 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]

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

$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";

Link to comment
Share on other sites

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?

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.