alevsky Posted January 3, 2008 Share Posted January 3, 2008 Hi I am not that greate with php ,so I am hopping that some of you will be able to help me. Problem some what simple... I need mail form ( and I try about 15-20 of the availiabe) that could do very simple function, when user sended it, form must deliver two copy one to a person this email ment to be sent and a copy sholud be sent to a sender of the email. Ok so if any one know a form that can do that, I will greately appreciated. Thanx in advance Lev Quote Link to comment https://forums.phpfreaks.com/topic/84282-need-help/ Share on other sites More sharing options...
revraz Posted January 3, 2008 Share Posted January 3, 2008 Not really the right forum, but it's not too hard assuming your webhost supports PHP and Mail. contact.php <html> <body> <form method="POST" action="contact2.php"> <div id="contact"> <h2>All fields are required</h2> <p>Name:* <br /></p> <input type="text" name="Name"> <p>Comments:* <br /></p> <textarea name="Comments"></textarea> <p>Email:* <br /></p> <input type="text" name="Email"> <p><input type="submit" name="submit" value="Submit"></p> </div> </form> </body> </html> contact2.php <?php $Subject = "Your Subject"; $Name = trim(addslashes($_POST['Name'])); $Comments = trim(addslashes($_POST['Comments'])); $Email = trim(addslashes($_POST['Email'])); // validation $validationOK=true; if ($Name =="") $validationOK=false; if ($Comments =="") $validationOK=false; if ($Email =="") $validationOK=false; if (!$validationOK) { print "Missing Data"; echo "<meta http-equiv='refresh' content='2; URL=contact.php'>"; exit; } // prepare email body text $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "Comments: "; $Body .= $Comments; $Body .= "\n"; $Body .= "Email: "; $Body .= $Email; $Body .= "\n"; $EmailTo = "yourname@email.com, $Email"; //assuming commas work as a seperator, you may have to change this depending on what is an acceptable seperator // send email $success = mail($EmailTo, $Subject, $Body, "From: <$Email>"); // redirect to success page if ($success){ print "Email Sent"; echo "<meta http-equiv='refresh' content='2; URL=index.php'>"; } else{ print "Error, Email not Sent"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/84282-need-help/#findComment-429289 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.