nmrudolph Posted April 2, 2011 Share Posted April 2, 2011 I'm working on a site that has close to a hundred employees, each with an email address. They want me to add a feature to where people can contact these employees, without actually knowing their email address. To do that, I made a new window that pops up when they click to email someone, and it asks the user for their name, email address, and a short message. My problem is that the contact form is the same for every person. I don't know how to make that form direct to each individual person, without making each page by hand. (Something I don't want to do because there are so many and new employees being added all the time.) Thanks in advance to all you who are much wiser than I. Please let me know if you need more info or source code. Quote Link to comment https://forums.phpfreaks.com/topic/232496-contact-form-with-automated-content/ Share on other sites More sharing options...
Jnerocorp Posted April 2, 2011 Share Posted April 2, 2011 well i would say create a mysql table called "email_list" create 4 fields named: id fname lname email add all the emails and other info into the database then create a script similar to this we will call this page "email_someone.php" <?php //First you would need to connect to your mysql database ect... if(isset($_POST['send_email_now'])) { $fname = $_POST['fname']; $lname = $_POST['lname']; $message = $_POST['message']; $subject = $_POST['subject']; $myemail = $_POST['myemail']; $result = mysql_query("SELECT * FROM email_list WHERE fname='$fname' AND lname='$lname'") or die(mysql_error()); $row = mysql_fetch_array( $result ); $email = $row['email']; $to = '$email'; $subject = '$subject'; $message = '$message'; $headers = 'From: $myemail' . "\r\n" . 'Reply-To: $myemail' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); } else { ?> <form action="" method="post"> First Name: <input type="text" name="fname"><br> Last Name: <input type="text" name="lname"><br> Subject: <input type="text" name="subject"><br> Message:<br><textarea name="message"></textarea><br><br> Your email: <input type="text" name="myemail"><br> <input type="submit" name="send_email_now" value="Send"> <?php } ?> its pretty basic but it would work u would have to setup some of the stuff to for your own website though. Quote Link to comment https://forums.phpfreaks.com/topic/232496-contact-form-with-automated-content/#findComment-1195874 Share on other sites More sharing options...
nmrudolph Posted April 2, 2011 Author Share Posted April 2, 2011 Thanks for such an in depth reply! Will try it this weekend Quote Link to comment https://forums.phpfreaks.com/topic/232496-contact-form-with-automated-content/#findComment-1195928 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.