esoteric Posted July 7, 2011 Share Posted July 7, 2011 Hi. I'm trying to write a simple html/php form which i fill in and it will send an email. When a customer sends me a order form instead of having to write each reply manually i want a form on my website which i will password protect to send mail. It needs to be a form that i can fill in the text fields then hit send to email it too the 'customer email' address. customer email: [text field] (this is who the email will get sent too) customer name: [text field] order number: [text field] message: Thank you .. blah blah (standard message that will be sent to everyone) Log in information. your username [text field] your password [text field] I know the the above may look confusing but its hard to explain and im not that good at scripting so any help would be more than appreciated. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/241332-admin-send-email-to-customer-via-form/ Share on other sites More sharing options...
esoteric Posted July 7, 2011 Author Share Posted July 7, 2011 It may help if i show you the sort of thing im trying to do // mailto wont work as i would need to change the script everytime. <form method="post" action="mailto:customer@example.com"> <p>customer name</p> <input name="name" type="text" /> <p>customer email</p> <input name="name" type="text" /> <p>message</p> <textarea name="message" cols="" rows="">thank you for ... blah blah</textarea> <p><strong>customer login details</strong></p> <p>username</p> <input name="name" type="text" /> <p>password</p> <input name="name" type="text" /> <br /> <input name="submit" type="button" value="submit" /> </form> Once its all filled in i just want to hit submit for it too send to the customer obviously i need it to output a lot more pretty than that but hopefully it will help someone help me. Quote Link to comment https://forums.phpfreaks.com/topic/241332-admin-send-email-to-customer-via-form/#findComment-1239635 Share on other sites More sharing options...
esoteric Posted July 8, 2011 Author Share Posted July 8, 2011 been searching everywhere, there seems to be a ton of 'contact us' style forms where someone can send the website an email but im looking for the opposite where i send out a email 'template' and all i need to so i fill in a few text fields which will be the customer email addy, and to bits of info which is a username and password. email [i type customers email] to [i type in name] thanks you for ..blah blah... below is info you need to log in... (same message sends to everyone) username[text box i can fill in] p/w [text box i need to fill in] Really appreciate the help, sorry to be a pain but im struggling with this and i know there are some really smart people here. Quote Link to comment https://forums.phpfreaks.com/topic/241332-admin-send-email-to-customer-via-form/#findComment-1240024 Share on other sites More sharing options...
$php_mysql$ Posted July 8, 2011 Share Posted July 8, 2011 feel boring reading soo much lmao, so now aht do you want? a php page for ur mail from the from to be sent? Quote Link to comment https://forums.phpfreaks.com/topic/241332-admin-send-email-to-customer-via-form/#findComment-1240201 Share on other sites More sharing options...
jkewlo Posted July 8, 2011 Share Posted July 8, 2011 You could just query a database record with there name or even there ID number and have it the input field value set to the proper record and do a call fdrom there maybe even have ajax drop down menu with pre written messages that will fill in the body area.. could even have some php in the body to include the name of the person and other client information. Quote Link to comment https://forums.phpfreaks.com/topic/241332-admin-send-email-to-customer-via-form/#findComment-1240239 Share on other sites More sharing options...
$php_mysql$ Posted July 8, 2011 Share Posted July 8, 2011 Maybe this helps? <?php //error_reporting(0); if(count($_POST)){ $custReply = $_POST; /////////////////settings///////////////////// $user = "demo"; $pass = "demo"; $yourname = "My name"; $youremail = "your@emailaddress.com"; $subject = "Email Subject"; $message = "Thank you for ... blah blah"; $website = "www.yoursite.com"; /////////////////////////////////////////// if($custReply['username'] == "$user" || $custReply['password'] == "$pass"){ if(empty($custReply['custname']) || empty($custReply['custemail'])){ die ("Customer name or email filed is empty! <br/> <a href=\"email.php\"/>Return Back</a>"); } $to = "$custemail"; $subject = "$subject"; $message = "$message"; $subject = "$subject"; $custemail = $_POST['custemail']; $custname = $_POST['custname']; $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/plain; charset=iso-8859-1\n"; $headers = "From: $yourname<$youremail>\r\n"; $headers .= "X-Mailer: PHP's mail() Function\n"; $body = "Dear $custname, \n\n $message \n\n\n Regards, \n http://$website\n"; mail($to, $subject, $body, $headers); echo "<font color=\"green\" size=\"+2\">E-mail successfully sent to ($custname)!</font>"; }else{ echo "<font color=\"red\" size=\"+2\">Incorrect username or password!</font>"; } } ?> <html> <head> <title>Reply To Customer!</title> </head> <body> <form action="email.php" name="sendemail" method="post"/> <p>Customer name:</p> <input name="custname" type="text" value=""/> <p>Customer email:</p> <input name="custemail" type="text" value=""/> <p><strong>Customer login details!</strong></p> <p>Username:</p> <input name="username" type="text" value=""/> <p>Password:</p> <input name="password" type="password" value=""/> <br /> <input type="submit" name="submit" value="submit" /> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/241332-admin-send-email-to-customer-via-form/#findComment-1240258 Share on other sites More sharing options...
$php_mysql$ Posted July 8, 2011 Share Posted July 8, 2011 sorry my bad, just noticed i had $subject = "$subject"; 2 of them use this one <?php //error_reporting(0); if(count($_POST)){ $custReply = $_POST; /////////////////settings///////////////////// $user = "demo"; $pass = "demo"; $yourname = "My name"; $youremail = "your@emailaddress.com"; $subject = "Email Subject"; $message = "Thank you for ... blah blah"; $website = "www.yoursite.com"; /////////////////////////////////////////// if($custReply['username'] == "$user" || $custReply['password'] == "$pass"){ if(empty($custReply['custname']) || empty($custReply['custemail'])){ die ("Customer name or email filed is empty! <br/> <a href=\"email.php\"/>Return Back</a>"); } $to = "$custemail"; $subject = "$subject"; $message = "$message"; $custemail = $_POST['custemail']; $custname = $_POST['custname']; $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/plain; charset=iso-8859-1\n"; $headers = "From: $yourname<$youremail>\r\n"; $headers .= "X-Mailer: PHP's mail() Function\n"; $body = "Dear $custname, \n\n $message \n\n\n Regards, \n http://$website\n"; mail($to, $subject, $body, $headers); echo "<font color=\"green\" size=\"+2\">E-mail successfully sent to ($custname)!</font>"; }else{ echo "<font color=\"red\" size=\"+2\">Incorrect username or password!</font>"; } } ?> <html> <head> <title>Reply To Customer!</title> </head> <body> <form action="email.php" name="sendemail" method="post"/> <p>Customer name:</p> <input name="custname" type="text" value=""/> <p>Customer email:</p> <input name="custemail" type="text" value=""/> <p><strong>Customer login details!</strong></p> <p>Username:</p> <input name="username" type="text" value=""/> <p>Password:</p> <input name="password" type="password" value=""/> <br /> <input type="submit" name="submit" value="submit" /> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/241332-admin-send-email-to-customer-via-form/#findComment-1240302 Share on other sites More sharing options...
esoteric Posted July 9, 2011 Author Share Posted July 9, 2011 I owe you one sir, that's perfect, thank you. The only thing i need to change is it requires you to enter a username and password (demo) in order to send the mail, i needed the u/n and p/w boxes to be input field so i could write the account info in there and it would be sent to the customer. So the output would be something like; Dear cust, Thank you for ... blah blah Below you will find your login details.. username = (this is where the username field will appear) password = (and this one for password) Regards, http://www.website.co.uk I really appreciate for all your help. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/241332-admin-send-email-to-customer-via-form/#findComment-1240448 Share on other sites More sharing options...
esoteric Posted July 9, 2011 Author Share Posted July 9, 2011 I been having a try but it just leaves the username and password field blank, i'm probably being stupid but if you could have a quick look over it please <?php //error_reporting(0); if(count($_POST)){ $custReply = $_POST; /////////////////settings///////////////////// $yourname = "xxxxxxxxxx"; $youremail = "orders@xxxxxx.co.uk"; $subject = "Your Online Order"; $message = "Thank you for ... blah blah"; $message2 = "To check the status of your account please log in using the details below:"; $website = "www.xxxxxxxxxxx.co.uk"; /////////////////////////////////////////// if(empty($custReply['custname']) || empty($custReply['custemail'])){ die ("Customer name or email field is empty! <br/> <a href=\"email.php\"/>Return Back</a>"); } $to = "$custemail"; $subject = "$subject"; $message = "$message"; $message2 = "$message2"; $custuser = "$custuser"; $custpass = "$custpass"; $custemail = $_POST['custemail']; $custname = $_POST['custname']; $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/plain; charset=iso-8859-1\n"; $headers = "From: $yourname<$youremail>\r\n"; $headers .= "X-Mailer: PHP's mail() Function\n"; $body = "Dear $custname, \n\n $message \n\n $message2 \n Your Username: $custuser Your Password: $custpass \n\n\n Regards, \n http://$website\n"; mail($to, $subject, $body, $headers); echo "<font color=\"green\" size=\"+2\">E-mail successfully sent to ($custname)!</font>"; }else{ echo "<font color=\"red\" size=\"+2\">Mail Not Sent!</font>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/241332-admin-send-email-to-customer-via-form/#findComment-1240459 Share on other sites More sharing options...
$php_mysql$ Posted July 9, 2011 Share Posted July 9, 2011 yeah will do tht 2maro kinda druk now lol Quote Link to comment https://forums.phpfreaks.com/topic/241332-admin-send-email-to-customer-via-form/#findComment-1240651 Share on other sites More sharing options...
esoteric Posted July 11, 2011 Author Share Posted July 11, 2011 Have you had chance to look it over yet? Quote Link to comment https://forums.phpfreaks.com/topic/241332-admin-send-email-to-customer-via-form/#findComment-1241140 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.