spocek Posted July 24, 2007 Share Posted July 24, 2007 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. Link to comment https://forums.phpfreaks.com/topic/61453-solved-contact-form-input-fax-from-multiple-fields/ Share on other sites More sharing options...
teng84 Posted July 24, 2007 Share Posted July 24, 2007 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 https://forums.phpfreaks.com/topic/61453-solved-contact-form-input-fax-from-multiple-fields/#findComment-305860 Share on other sites More sharing options...
AndyB Posted July 24, 2007 Share Posted July 24, 2007 Just remember to have all your form fields with distinct/different names. You can't name them all Fax or they'll get overwritten. Link to comment https://forums.phpfreaks.com/topic/61453-solved-contact-form-input-fax-from-multiple-fields/#findComment-305865 Share on other sites More sharing options...
spocek Posted July 24, 2007 Author Share Posted July 24, 2007 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] Link to comment https://forums.phpfreaks.com/topic/61453-solved-contact-form-input-fax-from-multiple-fields/#findComment-306249 Share on other sites More sharing options...
spocek Posted July 24, 2007 Author Share Posted July 24, 2007 I guess this could be classified as a concatenation question... ??? Link to comment https://forums.phpfreaks.com/topic/61453-solved-contact-form-input-fax-from-multiple-fields/#findComment-306362 Share on other sites More sharing options...
AndyB Posted July 24, 2007 Share Posted July 24, 2007 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 https://forums.phpfreaks.com/topic/61453-solved-contact-form-input-fax-from-multiple-fields/#findComment-306680 Share on other sites More sharing options...
spocek Posted July 25, 2007 Author Share Posted July 25, 2007 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 https://forums.phpfreaks.com/topic/61453-solved-contact-form-input-fax-from-multiple-fields/#findComment-306773 Share on other sites More sharing options...
spocek Posted July 25, 2007 Author Share Posted July 25, 2007 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 https://forums.phpfreaks.com/topic/61453-solved-contact-form-input-fax-from-multiple-fields/#findComment-306820 Share on other sites More sharing options...
AndyB Posted July 25, 2007 Share Posted July 25, 2007 $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 https://forums.phpfreaks.com/topic/61453-solved-contact-form-input-fax-from-multiple-fields/#findComment-306829 Share on other sites More sharing options...
spocek Posted July 25, 2007 Author Share Posted July 25, 2007 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 https://forums.phpfreaks.com/topic/61453-solved-contact-form-input-fax-from-multiple-fields/#findComment-307214 Share on other sites More sharing options...
spocek Posted July 25, 2007 Author Share Posted July 25, 2007 It works - Thanks Andy!!! I modified your code (Trim needed to be capitalized), so the code I pasted works. You can ignore my comment about the periods. Link to comment https://forums.phpfreaks.com/topic/61453-solved-contact-form-input-fax-from-multiple-fields/#findComment-307229 Share on other sites More sharing options...
AndyB Posted July 26, 2007 Share Posted July 26, 2007 ... I modified your code (Trim needed to be capitalized) ... Not according to the manual - http://ca.php.net/manual/en/function.trim.php Link to comment https://forums.phpfreaks.com/topic/61453-solved-contact-form-input-fax-from-multiple-fields/#findComment-307535 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.