justspiffy Posted April 27, 2010 Share Posted April 27, 2010 Hi there, A client of mine has asked me to make them a form for their website, which I have completed without any issues. It emails them the information from the form, but now they are asking me if I can make it so it emails them it in a XML attachment so they can use it to import the data into this software they are using. I do not know anything about XML, and I only know basic PHP. I wonder if anyone can me some pointers on what I need to do from here. Here is the code I used for the form. <?php if ($_SERVER['REQUEST_METHOD'] != 'POST'){ $me = $_SERVER['PHP_SELF']; ?> <form name="form1" method="post" action="<?php echo $me;?>"> <FORM> .....</FORM> <?php } else { error_reporting(0); $recipient = '[email protected]'; $in_name = stripslashes($_POST['i_name']); $la_name = stripslashes($_POST['l_name']); $in_street = stripslashes($_POST['i_street']); $in_city_prov = stripslashes($_POST['i_city_prov']); $in_pcode = stripslashes($_POST['i_pcode']); $in_phone = stripslashes($_POST['i_phone']); $brokerage = stripslashes($_POST['brokerage']); $br_street = stripslashes($_POST['b_street']); $br_city_prov = stripslashes($_POST['b_city_prov']); $br_pcode = stripslashes($_POST['b_pcode']); $br_phone = stripslashes($_POST['b_phone']); $ext = stripslashes($_POST['ext']); $br_con_nam = stripslashes($_POST['b_con_nam']); $br_con_email = stripslashes($_POST['b_con_email']); $financed = stripslashes($_POST['p_financed']); $p_num1 = stripslashes($_POST['pol_num1']); $mon1 = stripslashes($_POST['month1']); $day1 = stripslashes($_POST['day1']); $yr1 = stripslashes($_POST['year1']); $ins_com1 = stripslashes($_POST['ins_com1']); $type1 = stripslashes($_POST['type1']); $t_mon_yr1 = stripslashes($_POST['term_mon_yr1']); $prem1 = stripslashes($_POST['premium1']); $fee1 = stripslashes($_POST['fees1']); $cfee1 = stripslashes($_POST['cfees1']); $tax1 = stripslashes($_POST['tax1']); $p_num2 = stripslashes($_POST['pol_num2']); $mon2 = stripslashes($_POST['month2']); $day2 = stripslashes($_POST['day2']); $yr2 = stripslashes($_POST['year2']); $ins_com2 = stripslashes($_POST['ins_com2']); $type2 = stripslashes($_POST['type2']); $t_mon_yr2 = stripslashes($_POST['term_mon_yr2']); $prem2 = stripslashes($_POST['premium2']); $fee2 = stripslashes($_POST['fees2']); $cfee2 = stripslashes($_POST['cfees2']); $tax2 = stripslashes($_POST['tax2']); $p_num3 = stripslashes($_POST['pol_num3']); $mon3 = stripslashes($_POST['month3']); $day3 = stripslashes($_POST['day3']); $yr3 = stripslashes($_POST['year3']); $ins_com3 = stripslashes($_POST['ins_com3']); $type3 = stripslashes($_POST['type3']); $t_mon_yr3 = stripslashes($_POST['term_mon_yr3']); $prem3 = stripslashes($_POST['premium3']); $fee3 = stripslashes($_POST['fees3']); $cfee3 = stripslashes($_POST['cfees3']); $tax3 = stripslashes($_POST['tax3']); $p_num4 = stripslashes($_POST['pol_num4']); $mon4 = stripslashes($_POST['month4']); $day4 = stripslashes($_POST['day4']); $yr4 = stripslashes($_POST['year4']); $ins_com4 = stripslashes($_POST['ins_com4']); $type4 = stripslashes($_POST['type4']); $t_mon_yr4 = stripslashes($_POST['term_mon_yr4']); $prem4 = stripslashes($_POST['premium4']); $fee4 = stripslashes($_POST['fees4']); $cfee4 = stripslashes($_POST['cfees4']); $tax4 = stripslashes($_POST['tax4']); $p_num5 = stripslashes($_POST['pol_num5']); $mon5 = stripslashes($_POST['month5']); $day5 = stripslashes($_POST['day5']); $yr5 = stripslashes($_POST['year5']); $ins_com5 = stripslashes($_POST['ins_com5']); $type5 = stripslashes($_POST['type5']); $t_mon_yr5 = stripslashes($_POST['term_mon_yr5']); $prem5 = stripslashes($_POST['premium5']); $fee5 = stripslashes($_POST['fees5']); $cfee5 = stripslashes($_POST['cfees5']); $tax5 = stripslashes($_POST['tax5']); $p_num6 = stripslashes($_POST['pol_num6']); $mon6 = stripslashes($_POST['month6']); $day6 = stripslashes($_POST['day6']); $yr6 = stripslashes($_POST['year6']); $ins_com6 = stripslashes($_POST['ins_com6']); $type6 = stripslashes($_POST['type6']); $t_mon_yr6 = stripslashes($_POST['term_mon_yr6']); $prem6 = stripslashes($_POST['premium6']); $fee6 = stripslashes($_POST['fees6']); $cfee6 = stripslashes($_POST['cfees6']); $tax6 = stripslashes($_POST['tax6']); $p_num7 = stripslashes($_POST['pol_num7']); $mon7 = stripslashes($_POST['month7']); $day7 = stripslashes($_POST['day7']); $yr7 = stripslashes($_POST['year7']); $ins_com7 = stripslashes($_POST['ins_com7']); $type7 = stripslashes($_POST['type7']); $t_mon_yr7 = stripslashes($_POST['term_mon_yr7']); $prem7 = stripslashes($_POST['premium7']); $fee7 = stripslashes($_POST['fees7']); $cfee7 = stripslashes($_POST['cfees7']); $tax7 = stripslashes($_POST['tax7']); $p_num8 = stripslashes($_POST['pol_num8']); $mon8 = stripslashes($_POST['month8']); $day8 = stripslashes($_POST['day8']); $yr8 = stripslashes($_POST['year8']); $ins_com8 = stripslashes($_POST['ins_com8']); $type8 = stripslashes($_POST['type8']); $t_mon_yr8 = stripslashes($_POST['term_mon_yr8']); $prem8 = stripslashes($_POST['premium8']); $fee8 = stripslashes($_POST['fees8']); $cfee8 = stripslashes($_POST['cfees8']); $tax8 = stripslashes($_POST['tax8']); $headers = "From: $br_con_email\r\n\r\n"; $subject = "Quick Quote Form from Website"; $message = "First Name: $in_name\r\n Last Name: $la_name\r\n Insured Street Address: $in_street\r\n Insured City & Province: $in_city_prov\r\n Insured Postal Code: $in_pcode\r\n Insured Phone Number: $in_phone\r\n Brokerage: $brokerage\r\n Broker Street Address: $br_street\r\n Broker City & Province: $br_city_prov\r\n Broker Postal Code: $br_pcode\r\n Broker Phone Number: $br_phone\r\n Broker Phone Ext: $ext\r\n Broker Name: $br_con_nam\r\n Broker Email: $br_con_email\r\n Policy Number: $p_num1 Effective Date: $mon1 $day1 $yr1 Ins. Company: $ins_com1 Type Of Coverage: $type1 Term: $t_mon_yr1 Policy Premium: $prem1 Policy Fee: $fee1 Company Fee: $cfee1 Sales Tax: $tax1 \r\n Policy Number: $p_num2 Effective Date: $mon2 $day2 $yr2 Ins. Company: $ins_com2 Type Of Coverage: $type2 Term: $t_mon_yr2 Policy Premium: $prem2 Policy Fee: $fee2 Company Fee: $cfee2 Sales Tax: $tax2 \r\n Policy Number: $p_num3 Effective Date: $mon3 $day3 $yr3 Ins. Company: $ins_com3 Type Of Coverage: $type3 Term: $t_mon_yr3 Policy Premium: $prem3 Policy Fee: $fee3 Company Fee: $cfee3 Sales Tax: $tax3 \r\n Policy Number: $p_num4 Effective Date: $mon4 $day4 $yr4 Ins. Company: $ins_com4 Type Of Coverage: $type4 Term: $t_mon_yr4 Policy Premium: $prem4 Policy Fee: $fee4 Company Fee: $cfee4 Sales Tax: $tax4 \r\n Policy Number: $p_num5 Effective Date: $mon5 $day5 $yr5 Ins. Company: $ins_com5 Type Of Coverage: $type5 Term: $t_mon_yr5 Policy Premium: $prem5 Policy Fee: $fee5 Company Fee: $cfee5 Sales Tax: $tax5 \r\n Policy Number: $p_num6 Effective Date: $mon6 $day6 $yr6 Ins. Company: $ins_com6 Type Of Coverage: $type6 Term: $t_mon_yr6 Policy Premium: $prem6 Policy Fee: $fee6 Company Fee: $cfee6 Sales Tax: $tax6 \r\n Policy Number: $p_num7 Effective Date: $mon7 $day7 $yr7 Ins. Company: $ins_com7 Type Of Coverage: $type7 Term: $t_mon_yr7 Policy Premium: $prem7 Policy Fee: $fee7 Company Fee: $cfee7 Sales Tax: $tax7 \r\n Policy Number: $p_num8 Effective Date: $mon8 $day8 $yr8 Ins. Company: $ins_com8 Type Of Coverage: $type8 Term: $t_mon_yr8 Policy Premium: $prem8 Policy Fee: $fee8 Company Fee: $cfee8 Sales Tax: $tax8 \r\n "; mail($recipient, $subject, $message, $headers); if (!mail) { echo "Message failed to send"; } else { echo nl2br ("<center><br><br><br><br><br><br><br><br><br><br>Thank you. Your request has been sent and we will contact you shortly.<br><br><br><br><br><br><br><br><br><br></center>"); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/199918-php-email-form-to-xml-attachment/ Share on other sites More sharing options...
dgoosens Posted April 27, 2010 Share Posted April 27, 2010 have a look at XMLWriter http://uk.php.net/manual/en/book.xmlwriter.php or at the Document Object Model (DOM) http://uk.php.net/manual/en/book.dom.php both are rather easy to use... Quote Link to comment https://forums.phpfreaks.com/topic/199918-php-email-form-to-xml-attachment/#findComment-1049335 Share on other sites More sharing options...
justspiffy Posted April 27, 2010 Author Share Posted April 27, 2010 Thanks for that, but I'm really not even sure where to begin! Do i have to redo this form, or it is just a case of adding some code to it? I'm quite lost Quote Link to comment https://forums.phpfreaks.com/topic/199918-php-email-form-to-xml-attachment/#findComment-1049349 Share on other sites More sharing options...
dgoosens Posted April 28, 2010 Share Posted April 28, 2010 no, there is nothing to change in your form script... but you should write a little function that returns a valid XML containing the form input then you'll be able to attach this XML file to the mail (I'd suggest you ZIP it though) Quote Link to comment https://forums.phpfreaks.com/topic/199918-php-email-form-to-xml-attachment/#findComment-1049734 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.