SteveH Posted November 4, 2009 Share Posted November 4, 2009 Hello I have an email script which works fine with an online form. This is the original form: <form action='#' style='display:none'> <label for='contact-name'>*Name:</label> <input type='text' id='contact-name' class='contact-input' name='name' tabindex='1001' /> <label for='contact-email'>*Email:</label> <input type='text' id='contact-email' class='contact-input' name='email' tabindex='1002' />"; if ($extra["form_subject"]) { $output .= " <label for='contact-subject'>Subject:</label> <input type='text' id='contact-subject' class='contact-input' name='subject' value='' tabindex='1003' />"; } $output .= " <label for='contact-message'>*Message:</label> <textarea id='contact-message' class='contact-input' name='message' cols='40' rows='4' tabindex='1004'></textarea> <br/>"; if ($extra["form_cc"]) { $output .= " <label> </label> <input type='checkbox' id='contact-cc' name='cc' value='1' tabindex='1005' /> <span class='contact-cc'>Send me a copy</span> <br/>"; } $output .= " <label> </label> <button type='submit' class='contact-send contact-button' tabindex='1006'>Send</button> <button type='submit' class='contact-cancel contact-button simplemodal-close' tabindex='1007'>Cancel</button> <br/> <input type='hidden' name='token' value='" . smcf_token($to) . "'/> </form> I have tried to add the following (after the message field), but get an error message: if ($extra["form_attachment"]) { $output .= " <label for='contact-attachment'>*Name:</label> <input type='text' id='contact-attachment' class='contact-input' name='name' tabindex='1001' /> <label for='contact-email'>Attachment:</label> <input type='text' id='contact-attachment' class='contact-input' name='attachment' tabindex='1002' />"; Any help would be appreciated. Thanks. Steve Quote Link to comment Share on other sites More sharing options...
Bricktop Posted November 4, 2009 Share Posted November 4, 2009 Hi Steve, You're not closing the above code with a closing } bracket. Change your code to read: if ($extra["form_attachment"]) { $output .= " <label for='contact-attachment'>*Name:</label> <input type='text' id='contact-attachment' class='contact-input' name='name' tabindex='1001' /> <label for='contact-email'>Attachment:</label> <input type='text' id='contact-attachment' class='contact-input' name='attachment' tabindex='1002' />"; } Hope this helps. Quote Link to comment Share on other sites More sharing options...
SteveH Posted November 5, 2009 Author Share Posted November 5, 2009 Hello Bricktop Thanks for your post. That's got rid of the error, cheers. I have also added the attachment here: // Include extra form fields and/or submitter data? // false = do not include $extra = array( "form_subject" => true, "form_cc" => true, [b]"form_attachment" => true,[/b]"ip" => true, "user_agent" => true ); and wondered if I also needed to add attachment in the script below: else if ($action == "send") { // Send the email $name = isset($_POST["name"]) ? $_POST["name"] : ""; $email = isset($_POST["email"]) ? $_POST["email"] : ""; $subject = isset($_POST["subject"]) ? $_POST["subject"] : $subject; $message = isset($_POST["message"]) ? $_POST["message"] : ""; $cc = isset($_POST["cc"]) ? $_POST["cc"] : ""; $token = isset($_POST["token"]) ? $_POST["token"] : ""; // make sure the token matches if ($token === smcf_token($to)) { smcf_send($name, $email, $subject, $message, $cc); echo "Your message was successfully sent."; } else { echo "Unfortunately, your message could not be verified."; } } Thanks again for any advice. Steve Quote Link to comment Share on other sites More sharing options...
Bricktop Posted November 5, 2009 Share Posted November 5, 2009 Hi Steve, Give the following a try: else if ($action == "send") { // Send the email $name = isset($_POST["name"]) ? $_POST["name"] : ""; $email = isset($_POST["email"]) ? $_POST["email"] : ""; $subject = isset($_POST["subject"]) ? $_POST["subject"] : $subject; $message = isset($_POST["message"]) ? $_POST["message"] : ""; $cc = isset($_POST["cc"]) ? $_POST["cc"] : ""; $token = isset($_POST["token"]) ? $_POST["token"] : ""; //Grab the two new $_POST values and assign them to variables $attachmentname = isset($_POST["name"]) ? $_POST["name"] : ""; $attachment = isset($_POST["attachment"]) ? $_POST["attachment"] : ""; //Create a new $message variable, combining $message, $attachmentname and $attachment $message = "Message: $message\n\nAttachment Name: $attachmentname\n\nAttachment: $attachment\n\n" // make sure the token matches if ($token === smcf_token($to)) { smcf_send($name, $email, $subject, $message, $cc); echo "Your message was successfully sent."; } else { echo "Unfortunately, your message could not be verified."; } } Hopefully the above should do what you want, it will send the contents of the attachment name and attachment fields in the main email body. Hope this helps. Quote Link to comment 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.