PopSCicle helped me design this tell a friend page --> I'm a PHP novice but need a contact form, could someone please alter it that it'll work as a contact page eg name, telephone, email, and textarea --> no validation is needed, just exactly the same as it is so the thank you message appears on the same page as the form. email address for the info to be sent to is: <?php if (isset($_POST['Submit'])) { // This will check to see if the form has been submitted $senders_name = $_POST['your_name']; $headers .= "From: <langbakk@gmail.com>\n"; // your email client will show the person's email address like normal $headers .= "Content-Type: text/plain; charset=iso-8859-1\n"; // sets the mime type $subject = "Your Friend, $senders_name, has recommended Villa.com"; // this is the subject of the email // The person who is submitting the form $recipient_friend = $_POST['friend_email']; // The forms recipient mail($recipient_friend, $subject, "Dear $recipient_friend,\n\n Your friend $senders_name, recommends this site.\n\n Please click here:\nhttp://www.Villa.com \n\nRegards\n\nVilla.com", $headers); } else { ?> <form action="test.php" method="post"> <fieldset> <legend>Tell a friend</legend><br /> Your email<br /> <input type="text" name="your_email" value="Your email" /><br /><br /> Your Friends email<br /> <input type="text" name="friend_email" value="Your friends email" /> <input type="Submit" value="Tell a friend" name="Submit" /> </fieldset> </form> <?php } if (isset($_POST['your_email'])) { ?> <p>Your friend <?php echo $recipient_friend; ?> has been contacted</p> <p>Thank you <?php echo $senders_email; ?></p> <?php } ?> PHP:
It's a bit messy but OK. Modified a bit; <?php if (isset($_POST['Submit'])) { // This will check to see if the form has been submitted $senders_name = $_POST['your_name']; $headers .= "From: <".$_POST['your_email'].">\n"; // your email client will show the person's email address like normal $headers .= "Content-Type: text/plain; charset=iso-8859-1\n"; // sets the mime type $subject = "Your Friend, ".$senders_name.", has recommended Villa.com"; // this is the subject of the email // The person who is submitting the form $recipient_friend = $_POST['friend_email']; // The forms recipient mail($recipient_friend, $subject, "Dear $recipient_friend,\n\n Your friend $senders_name, recommends this site.\n\n Please click here:\nhttp://www.Villa.com \n\nRegards\n\nVilla.com", $headers); } else { ?> <form action="test.php" method="post"> <fieldset> <legend>Tell a friend</legend><br /> Your Name<br /> <input type="text" name="your_name" value="Your name" /><br /><br /> Your email<br /> <input type="text" name="your_email" value="Your email" /><br /><br /> Your Friends email<br /> <input type="text" name="friend_email" value="Your friends email" /> <input type="Submit" value="Tell a friend" name="Submit" /> </fieldset> </form> <?php } if (isset($_POST['your_email'])) { ?> <p>Your friend <?php echo $recipient_friend; ?> has been contacted</p> <p>Thank you <?php echo $senders_email; ?></p> <?php } ?> PHP: I'm not exactly sure what you need...
Here's a working contact form, based on the same code: <?php if (isset($_POST['submit'])) { // This will check to see if the form has been submitted $senders_name = $_POST['first_name']." ".$_POST['sur_name']; $phone = $_POST['phone']; $email = $_POST['your_email']; $message = $_POST['message']; $recipient = "write_your_email_here"; $headers .= "From: $email\n"; // your email client will show the person's email address like normal $headers .= "Content-Type: text/plain; charset=iso-8859-1\n"; // sets the mime type $subject = "$senders_name, has sent a contact form from Villa.com"; // this is the subject of the email //we send the email mail($recipient, $subject, "$senders_name\n$phone\n$message", $headers); } else { ?> <form action="testcontact.php" method="post"> <fieldset> <legend>Contact us:</legend> <p><label>First name:</label><br /> <input type="text" name="first_name" value="" /></p> <p><label>Surname:</label><br /> <input type="text" name="sur_name" value="" /></p> <p><label>Phone:</label><br /> <input type="text" name="phone" value="" /></p> <p><label>Your email</label><br /> <input type="text" name="your_email" value="" /></p> <p><label>Message:</label><br /> <textarea rows="10" cols="70" name="message"></textarea></p> <p><input type="Submit" value="Send message" name="submit" /></p> </fieldset> </form> <?php } if (isset($_POST['submit'])) { ?> <p>You sent the following message:</p> <p><?php echo "$recipient\n$senders_name\n$phone\n$your_email\n$message"; ?></p> <p>Thank you <?php echo $senders_email; ?></p> <?php } ?> PHP: Although it's not good practice to not have any error-checking etc.