Jump to content

BeckyKing

Members
  • Posts

    25
  • Joined

  • Last visited

Everything posted by BeckyKing

  1. Hi, I have the attached the files that I am using but when the form is filled out nothing comes through to any email addresses? Can anyone give any advice as to why? Thank you in advance. Regards, Becky index.php contact-form-submission.php
  2. i HAVE NOW MANAGED TO FIXED THE ISSUE. THANK YOU VERY MUCH FOR YOUR HELP!!!!
  3. I ahve changed thye code so the headers only have one rn after it but still throws the Warning: mail(): Multiple or malformed newlines found in additional_header in /home/westover/public_html/contact-form-submission.php on line 267 but only one error this time. The "headers already sent" message shows up because the mail error message is considered output, and there cannot be output before you send headers ​What is my mail error message? Line 247? I have tried to put this at the end of the code but still gives an error? Thank you for your help.
  4. Hi, I have created a form and up until Friday it was working correctly but now get the error: Warning: mail(): Multiple or malformed newlines found in additional_header in /home/westover/public_html/contact-form-submission.php on line 267 Warning: mail(): Multiple or malformed newlines found in additional_header in /home/westover/public_html/contact-form-submission.php on line 267Warning: mail(): Multiple or malformed newlines found in additional_header in /home/westover/public_html/contact-form-submission.php on line 267Warning: mail(): Multiple or malformed newlines found in additional_header in /home/westover/public_html/contact-form-submission.php on line 267Warning: Cannot modify header information - headers already sent by (output started at /home/westover/public_html/contact-form-submission.php:267) in /home/westover/public_html/contact-form-submission.php on line 247 // send the user back to the formLine 247: header('Location: index.php?s='.urlencode('Thank you for your message.')); exit;function mail_attachment($to, $subject, $message, $from, $data, $test2) { $content = chunk_split(base64_encode($data)); $uid = md5(uniqid(time())); $from = str_replace(array("r", "n"), '', $from); // to prevent email injection $header = "From: ".$from."rn" ."MIME-Version: 1.0rn" ."Content-Type: multipart/mixed; boundary="".$uid.""rnrn" ."This is a multi-part message in MIME format.rn" ."--".$uid."rn" ."Content-type:text/plain; charset=iso-8859-1rn" ."Content-Transfer-Encoding: 7bitrnrn" .$message."rnrn" ."--".$uid."rn" ."Content-Type: application/octet-stream; name="".$test2.""rn" ."Content-Transfer-Encoding: base64rn" ."Content-Disposition: attachment; filename="".$test2.""rnrn" .$content."rnrn" ."--".$uid."--"; Line 267: return mail($to, $subject, "", $header);}?> I have highlighted which lines the error is talking about. Any advice is welcome. Thank you in advance!!
  5. If I add radio buttons to my form will that go on to the XML attachment the same as the other fields or is it different?
  6. New it would be something simple. great thank you so much for all your help :-)
  7. I have used $xmlroot->appendChild($xmlindividual); and tried $xmlroot->appendChild($xmlfirstname); But keep getting and error 'Fatal error: Call to a member function appendChild() on a non-object in /websites/123reg/LinuxPackage22/ki/ng/_c/king-creations.co.uk/public_html/beckyking/contact-form-submission.php on line 23' Code: <?php /* Create XML Document */ $xmlDoc = new DOMDocument('1.0'); /* Build Maximizer XML file */ $xmlRoot = $xmlDoc->createElement('AllData'); $xmlDoc->appendChild($xmlRoot); $xmlIndividual = $xmlDoc->createElement('Individual'); $firstname = $_POST["firstname"]; $surname = $_POST["surname"]; $email = $_POST["email"]; $phone = $_POST["phone"]; $brand = $_POST["brand"]; $vehmodel = $_POST["vehmodel"]; $vehcolor = $_POST["vehcolor"]; $contact_message = $_POST["contact_message"]; $xmlfirstname = $xmlDoc->createElement('firstname', $firstname); $xmlIndividual->appendChild($xmlfirstname); $xmlroot->appendChild($xmlIndividual); "<<<<--- line 23 " $xmlsurname = $xmlDoc->createElement('surname', $surname); $xmlIndividual->appendChild($xmlsurname); $xmlroot->appendChild($xmlIndividual); $xmlemail = $xmlDoc->createElement('email', $email); $xmlIndividual->appendChild($xmlemail); $xmlroot->appendChild($xmlIndividual); $xmlphone = $xmlDoc->createElement('phone', $phone); $xmlIndividual->appendChild($xmlphone); $xmlroot->appendChild($xmlIndividual); $xmlbrand = $xmlDoc->createElement('brand', $brand); $xmlIndividual->appendChild($xmlbrand); $xmlroot->appendChild($xmlIndividual); $xmlvehmodel = $xmlDoc->createElement('vehmodel', $vehmodel); $xmlIndividual->appendChild($xmlvehmodel); $xmlroot->appendChild($xmlIndividual); $xmlvehcolor = $xmlDoc->createElement('vehcolor', $vehcolor); $xmlIndividual->appendChild($xmlvehcolor); $xmlroot->appendChild($xmlIndividual); $xmlmessage = $xmlDoc->createElement('contact_message', $contact_message); $xmlIndividual->appendChild($xmlmessage); $xmlroot->appendChild($xmlIndividual); /* No need to create an actual file, just use the content of the created XML document */ $content = $xmlDoc->saveXML(); // check for form submission - if it doesn't exist then send back to contact form if (!isset($_POST['save']) || $_POST['save'] != 'contact') { header('Location: contact.php'); exit; } // get the posted data $firstname = $_POST['firstname']; $surname = $_POST['surname']; $email = $_POST['email']; $phone = $_POST['phone']; $brand = $_POST['brand']; $vehmodel = $_POST['vehmodel']; $vehcolor = $_POST['vehcolor']; $message = $_POST['contact_message']; // check that a name was entered if (empty($firstname)) $error = 'You must enter your name.'; // check that an surname was entered elseif (empty($surname)) $error = 'You must enter your surname.'; // check that a phone number was entered if (empty($phone)) $error = 'You must enter your phone number.'; // check that an email address was entered elseif (empty($email)) $error = 'You must enter an email address.'; // check for a valid email address elseif (!preg_match('/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/', $email)) $error = 'You must enter a valid email address.'; // check that a phone number was entered if (empty($phone)) $error = 'You must enter your phone number.'; // check that a Franchise was entered if (empty($brand)) $error = 'You must enter a Franchise.'; // check that a message was entered elseif (empty($message)) $error = 'You must enter a message.'; // check if an error was found - if there was, send the user back to the form if (isset($error)) { header('Location: contact.php?e='.urlencode($error)); exit; } // write the email content $email_content = "First Name: $firstnamen"; $email_content .= "Surname: $surnamen"; $email_content .= "Email: $emailn"; $email_content .= "Phone Number: $phonen"; $email_content .= "Franchise: $brandn"; $email_content .= "Model: $vehmodeln"; $email_content .= "Colour: $vehcolorn"; $email_content .= "Message:nn$message"; mail_attachment('becky.king99@gmail.com', 'Westover', $email_content, $email, $content, 'test2.xml'); // send the user back to the form header('Location: contact.html?s='.urlencode('Thank you for your message.')); exit; function mail_attachment($to, $subject, $message, $from, $data, $test2) { $content = chunk_split(base64_encode($data)); $uid = md5(uniqid(time())); $from = str_replace(array("r", "n"), '', $from); // to prevent email injection $header = "From: ".$from."rn" ."MIME-Version: 1.0rn" ."Content-Type: multipart/mixed; boundary="".$uid.""rnrn" ."This is a multi-part message in MIME format.rn" ."--".$uid."rn" ."Content-type:text/plain; charset=iso-8859-1rn" ."Content-Transfer-Encoding: 7bitrnrn" .$message."rnrn" ."--".$uid."rn" ."Content-Type: application/octet-stream; name="".$test2.""rn" ."Content-Transfer-Encoding: base64rn" ."Content-Disposition: attachment; filename="".$test2.""rnrn" .$content."rnrn" ."--".$uid."--"; return mail($to, $subject, "", $header); } ?>
  8. how do I append the node to the root node?
  9. Is there anything else I can try?
  10. It has the same as my attachment which is: <?xml version="1.0"?> <AllData/>
  11. I know its probably simple but I keep getting errors when I try to print out the variable $content? What is the best code to use and where abouts do I put it?
  12. I have moved the code to where you said but my XML is still not being generated. Do i need to write anything in the XML document or write the XML code in the PHP? <?php /* Create XML Document */ $xmlDoc = new DOMDocument('1.0'); /* Build Maximizer XML file */ $xmlRoot = $xmlDoc->createElement('AllData'); $xmlDoc->appendChild($xmlRoot); $xmlIndividual = $xmlDoc->createElement('Individual'); $contact_name = $_POST["contact_name"]; $contact_email = $_POST["contact_email"]; $contact_phone = $_POST["contact_phone"]; $contact_message = $_POST["contact_message"]; $xmlname = $xmlDoc->createElement('contact_name', $contact_name); $xmlIndividual->appendChild($xmlname); $xmlemail_address = $xmlDoc->createElement('contact_email', $contact_email); $xmlIndividual->appendChild($xmlemail_address); $xmlphone = $xmlDoc->createElement('contact_phone', $contact_phone); $xmlIndividual->appendChild($xmlphone); $xmlmessage = $xmlDoc->createElement('contact_message', $contact_message); $xmlIndividual->appendChild($xmlmessage); /* No need to create an actual file, just use the content of the created XML document */ $content = $xmlDoc->saveXML(); // check for form submission - if it doesn't exist then send back to contact form if (!isset($_POST['save']) || $_POST['save'] != 'contact') { header('Location: contact.php'); exit; } // get the posted data $name = $_POST['contact_name']; $email_address = $_POST['contact_email']; $phone = $_POST['contact_phone']; $message = $_POST['contact_message']; // check that a name was entered if (empty($name)) $error = 'You must enter your name.'; // check that an email address was entered elseif (empty($email_address)) $error = 'You must enter your email address.'; // check for a valid email address elseif (!preg_match('/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/', $email_address)) $error = 'You must enter a valid email address.'; // check that a phone number was entered if (empty($phone)) $error = 'You must enter your phone number.'; // check that a message was entered elseif (empty($message)) $error = 'You must enter a message.'; // check if an error was found - if there was, send the user back to the form if (isset($error)) { header('Location: contact.php?e='.urlencode($error)); exit; } // write the email content $email_content = "Name: $namen"; $email_content .= "Email Address: $email_addressn"; $email_content .= "Phone Number: $phonen"; $email_content .= "Message:nn$message"; mail_attachment('becky.king99@gmail.com', 'Westover', $email_content, $email_address, $content, 'test2.xml'); // send the user back to the form header('Location: contact.html?s='.urlencode('Thank you for your message.')); exit; function mail_attachment($to, $subject, $message, $from, $data, $test2) { $content = chunk_split(base64_encode($data)); $uid = md5(uniqid(time())); $from = str_replace(array("r", "n"), '', $from); // to prevent email injection $header = "From: ".$from."rn" ."MIME-Version: 1.0rn" ."Content-Type: multipart/mixed; boundary="".$uid.""rnrn" ."This is a multi-part message in MIME format.rn" ."--".$uid."rn" ."Content-type:text/plain; charset=iso-8859-1rn" ."Content-Transfer-Encoding: 7bitrnrn" .$message."rnrn" ."--".$uid."rn" ."Content-Type: application/octet-stream; name="".$test2.""rn" ."Content-Transfer-Encoding: base64rn" ."Content-Disposition: attachment; filename="".$test2.""rnrn" .$content."rnrn" ."--".$uid."--"; return mail($to, $subject, "", $header); } ?>
  13. I have moved the code to the top but it still will not create the data for the XML document?
  14. This didn't seem to work? <?php /* Create XML Document */ $xmlDoc = new DOMDocument('1.0'); /* Build Maximizer XML file */ $xmlRoot = $xmlDoc->createElement('AllData'); $xmlDoc->appendChild($xmlRoot); $xmlIndividual = $xmlDoc->createElement('Individual'); $xmlname = $xmlDoc->createElement('contact_name', $name); $xmlIndividual->appendChild($xmlname); $name = $_POST["contact_name"]; $xmlemail_address = $xmlDoc->createElement('contact_email', $email_address); $xmlIndividual->appendChild($xmlemail_address); $email_address = $_POST["contact_email"]; $xmlphone = $xmlDoc->createElement('contact_phone', $phone_number); $xmlIndividual->appendChild($xmlphone); $phone_number = $_POST["contact_phone"]; $xmlmessage = $xmlDoc->createElement('contact_message', $message); $xmlIndividual->appendChild($xmlmessage); $message = $_POST["contact_message"]; /* No need to create an actual file, just use the content of the created XML document */ $content = $xmlDoc->saveXML(); // check for form submission - if it doesn't exist then send back to contact form if (!isset($_POST['save']) || $_POST['save'] != 'contact') { header('Location: contact.php'); exit; } // get the posted data $name = $_POST['contact_name']; $email_address = $_POST['contact_email']; $phone = $_POST['contact_phone']; $message = $_POST['contact_message']; // check that a name was entered if (empty($name)) $error = 'You must enter your name.'; // check that an email address was entered elseif (empty($email_address)) $error = 'You must enter your email address.'; // check for a valid email address elseif (!preg_match('/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/', $email_address)) $error = 'You must enter a valid email address.'; // check that a phone number was entered if (empty($phone)) $error = 'You must enter your phone number.'; // check that a message was entered elseif (empty($message)) $error = 'You must enter a message.'; // check if an error was found - if there was, send the user back to the form if (isset($error)) { header('Location: contact.php?e='.urlencode($error)); exit; } // write the email content $email_content = "Name: $namen"; $email_content .= "Email Address: $email_addressn"; $email_content .= "Phone Number: $phonen"; $email_content .= "Message:nn$message"; mail_attachment('becky.king99@gmail.com', 'Westover', $email_content, $email_address, $content, 'test2.xml'); // send the user back to the form header('Location: contact.html?s='.urlencode('Thank you for your message.')); exit; function mail_attachment($to, $subject, $message, $from, $data, $test2) { $content = chunk_split(base64_encode($data)); $uid = md5(uniqid(time())); $from = str_replace(array("r", "n"), '', $from); // to prevent email injection $header = "From: ".$from."rn" ."MIME-Version: 1.0rn" ."Content-Type: multipart/mixed; boundary="".$uid.""rnrn" ."This is a multi-part message in MIME format.rn" ."--".$uid."rn" ."Content-type:text/plain; charset=iso-8859-1rn" ."Content-Transfer-Encoding: 7bitrnrn" .$message."rnrn" ."--".$uid."rn" ."Content-Type: application/octet-stream; name="".$test2.""rn" ."Content-Transfer-Encoding: base64rn" ."Content-Disposition: attachment; filename="".$test2.""rnrn" .$content."rnrn" ."--".$uid."--"; return mail($to, $subject, "", $header); } ?> Form: <form role="form" method="POST" action="contact-form-submission.php"> <div class="row"> <div class="form-group col-lg-4"> <label for="input1">Name</label> <input type="text" name="contact_name" class="form-control" id="input1"> </div> <div class="form-group col-lg-4"> <label for="input2">Email Address</label> <input type="email" name="contact_email" class="form-control" id="input2"> </div> <div class="form-group col-lg-4"> <label for="input3">Phone Number</label> <input type="phone" name="contact_phone" class="form-control" id="input3"> </div> <div class="clearfix"></div> <div class="form-group col-lg-12"> <label for="input4">Message</label> <textarea name="contact_message" class="form-control" rows="6" id="input4"></textarea> </div> <div class="form-group col-lg-12"> <input type="hidden" name="save" value="contact"> <button type="submit" class="btn btn-primary">Submit</button> </div> </div> </form>
  15. Can you give me an example please?
  16. Thank you for your help I have a fully working form that attaches the xml document. My problem now is that the information is not being transferred onto the xml document? so when i open the xml document attachment there is no information?
  17. How do I now attach the xml doc? Thats if I have done the creating of the xml doc correct? Form: <form role="form" method="POST" action="contact-form-submission.php"> <div class="row"> <div class="form-group col-lg-4"> <label for="input1">Name</label> <input type="text" name="contact_name" class="form-control" id="input1"> </div> <div class="form-group col-lg-4"> <label for="input2">Email Address</label> <input type="email" name="contact_email" class="form-control" id="input2"> </div> <div class="form-group col-lg-4"> <label for="input3">Phone Number</label> <input type="phone" name="contact_phone" class="form-control" id="input3"> </div> <div class="clearfix"></div> <div class="form-group col-lg-12"> <label for="input4">Message</label> <textarea name="contact_message" class="form-control" rows="6" id="input4"></textarea> </div> <div class="form-group col-lg-12"> <input type="hidden" name="save" value="contact"> <button type="submit" class="btn btn-primary">Submit</button> </div> </div> </form> PHP: <?php /* Create XML Document */ $xmlDoc = new DOMDocument('1.0'); /* Build Maximizer XML file */ $xmlRoot = $xmlDoc->createElement('AllData'); $xmlDoc->appendChild($xmlRoot); $xmlIndividual = $xmlDoc->createElement('Individual'); $xmlname = $xmlDoc->createElement('contact_name', $input_name); $xmlIndividual->appendChild($xmlname); $xmlemail_address = $xmlDoc->createElement('contact_email', $input_email_address); $xmlIndividual->appendChild($xmlemail_address); $xmlphone = $xmlDoc->createElement('contact_phone', $input_phone); $xmlIndividual->appendChild($xmlphone); $xmlmessage = $xmlDoc->createElement('contact_message', $input_message); $xmlIndividual->appendChild($xmlmessage); $content = chunk_split(base64_encode($xmlDoc->saveXML())); /* No need to create an actual file, just use the content of the created XML document */ $content = $xmlDoc->saveXML(); // check for form submission - if it doesn't exist then send back to contact form if (!isset($_POST['save']) || $_POST['save'] != 'contact') { header('Location: contact.php'); exit; } // get the posted data $name = $_POST['contact_name']; $email_address = $_POST['contact_email']; $phone = $_POST['contact_phone']; $message = $_POST['contact_message']; // check that a name was entered if (empty($name)) $error = 'You must enter your name.'; // check that an email address was entered elseif (empty($email_address)) $error = 'You must enter your email address.'; // check for a valid email address elseif (!preg_match('/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/', $email_address)) $error = 'You must enter a valid email address.'; // check that a phone number was entered if (empty($phone)) $error = 'You must enter your phone number.'; // check that a message was entered elseif (empty($message)) $error = 'You must enter a message.'; // check if an error was found - if there was, send the user back to the form if (isset($error)) { header('Location: contact.php?e='.urlencode($error)); exit; } $headers = "From: $email_addressrn"; $headers .= "Reply-To: $email_addressrn"; // write the email content $email_content = "Name: $namen"; $email_content .= "Email Address: $email_addressn"; $email_content .= "Phone Number: $phonen"; $email_content .= "Message:nn$message"; // send the email //ENTER YOUR INFORMATION BELOW FOR THE FORM TO WORK! mail ('becky.king99@gmail.com', 'Westover', $email_content, $headers); // send the user back to the form header('Location: contact.html?s='.urlencode('Thank you for your message.')); exit; ?>
  18. Thank you. I am very new to PHP and XML and still abit confused. Any chance anyone can give me abit of code to work with? I have the PHP form just need the bit where I add the XML attachment. I know there were a lot of examples in those links but as I said still confused. Thank you in advance
  19. I want to create a PHP form that sends the details from the form as a XML attachment. What is the easiest way to do this?
  20. Great thank you for your help. I will try this out :-)
  21. Do you know any tutorials which could help me with this?
  22. Which is what I was planning on doing but how do I get the name 'Dear Miss King' into that link? There will be loads of other emails that I will be sending with different names.
  23. I have recived an email from Hargreaves and it says 'Dear Miss King'. I clicked on 'View in browser' and this is the link I get. I want to do exactly what they have done and have 'Dear Miss King' on the link as per below. http://links.h-l.co.uk/servlet/MailView?ms=NDU4MDU2MzYS1&r=OTE1NDQwNDY0NTAS1&j=NDQwNzM1ODQ3S0&mt=1&rt=0
  24. So on a email you will have a 'view in your browser' if the email does not display correctly which will show the email in your browser. The email will have a customers name on the email and I want that display if the click the link? Hope that makes more sense.
  25. I have recently built and designed a HTML email which is fine and working. What I need to create now is the 'view in your browser' link and the page to include the customers name which is on the email? Also I need to create an unsubscribe page which I don't know if possible could link to a spreadsheet or if I need a mysql database or if it easier to just send myself an email. If anyone could help it would be much appreciated.
×
×
  • Create New...