Hi, I have a simple html form.
<form action="mail.php" method="POST">
<p>Name</p> <input type="text" name="name">
<p>Email</p> <input type="text" name="email">
<p>Phone</p> <input type="text" name="phone">
<p>Message</p><textarea name="message" rows="6" cols="25"></textarea><br />
<input type="submit" value="Send"><input type="reset" value="Clear">
</form>
I send a simple recap to e-mail through PHP. Simultaneously with this recapitulation, I would like to generate XML, which would send it in an e-mail attachment. Somehow it's not working. Would anyone help?
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$formcontent=" From: $name \n Phone: $phone \n Call Back: $call \n Website: $website \n Priority: $priority \n Type: $type \n Message: $message";
$recipient = "**************";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
$doc = new DOMDocument('1.0', 'UTF-8');
$doc->formatOutput = true;
$xmlRoot = $doc->createElement("xml");
$xmlRoot = $doc->appendChild($xmlRoot);
$root = $doc->createElement('OrderDetails');
$root = $doc->appendChild($root);
$ele1 = $doc->createElement('name');
$ele1->nodeValue=$name;
$root->appendChild($ele1);
$xml->saveXML("");
$mail->addStringAttachment($xml->asXML(), "xml.xml");
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!" . " -" . "<a href='form.html' style='text-decoration:none;color:#ff0099;'> Return Home</a>";
?>
Thanks for any help!!