utdfederation Posted August 20, 2008 Share Posted August 20, 2008 hello again,i am probably going to get spanked for this. i have abandoned my previous contact form as i found this very nice contact form. i am however a tad stuck.all i want to do now is add a dropdown with 5 contacts to choose from, the user then selects the contact he/she wants to get a hold of and sends the email to them so in essense each contact will have their own e-mail attatched to the named contact,but i don't know how to script it. i have attatched the script i am trying to modify where i have tried to incorporate a piece of script from another script but it not working,wonders will never cease. i am trying honest,just guessing now but would appreciate any help here please. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <?php if (isset($_POST['submitted'])) { // Handle the form. //Check for Contact chosen $webmaster = ($_POST['contact']); if ($webmaster==0) $error = "Please select admin"; switch ($webmaster) { case "your@email.com": // assign email address for contact1 $subject = "WebContact"; // assign subject line for contact1 break; case "your@email.com": // assign email address for contact2 $subject = "WebContact"; // assign subject line for contact2 break; case "your@email.com": // assign email address for contact3 $subject = "WebContact"; // assign subject line for contact3 break; case "your@email.com": // assign email address for contact4 $subject = "WebContact"; // assign subject line for contact4 break; case "your@email.com": // assign email address for contact5 $subject = "WebContact"; // assign subject line for contact5 break; } //User info $name = stripslashes($_POST['name']); $email = stripslashes($_POST['email']); //The subject $subject = "WebContact "; $subject .= stripslashes($_POST['subject']); $msg = "From : $name \r\n"; $msg .= "e-Mail : $email \r\n"; $msg .= "Subject : $subject \r\n\n"; $msg .= "---Message--- \r\n".stripslashes($_POST['message'])."\r\n\n"; ?> <head> <title>Contact Us</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="css/main.css" type="text/css" media="screen" /> <meta name="description" content="Ajax Contact form using CheckForm2 and NiceForms." /> <meta name="keywords" content="php, contact form, Ajax, mootools, checkform2, niceforms, Moo Floor, class, javascript, spamcheck, badboy.ro" /> <meta name="author" content="Jeremie Tisseau" /> <link rel="stylesheet" href="js/formcheck/formcheck.css" type="text/css" media="screen" /> <script type="text/javascript" src="js/mootools.js"></script> <script type="text/javascript" src="js/formcheck/formcheck.js"></script> <script type="text/javascript"> window.addEvent('domready', function(){check = new FormCheck('third', { display : { fadeDuration : 500, errorsLocation : 1, indicateErrors : 1, showErrors : 1 } })}); </script> <link rel="stylesheet" href="js/niceform/niceforms-default.css" type="text/css" media="screen" /> <script type="text/javascript" src="js/niceform/niceforms.js"></script> </head> <body> <!-- The contact form starts here--> <?php if ($_SERVER['REQUEST_METHOD'] != 'POST'){ $self = $_SERVER['PHP_SELF']; ?> <!-- Start HTML form --> <form name="form" method="post" id="third" action="<?php echo $self;?>"> <h1>Contact Us</h1> <!-- Name --> <label for="name"><strong><span class="blue">*</span> Please Select a Contact : </strong></label> <select name="contact"> <option value="" selected="selected"></option> <!--------- INSERT APPROPRIATE EMAIL ADDRESS FOR EACH CONTACT ----------> <option value="your@email.com">contact1</option> <option value="your@email.com">contact2</option> <option value="your@email.com">contact3</option> <option value="your@email.com">contact4</option> <option value="your@email.com">contact5</option> </select> <!-- Name --> <label for="name"><strong><span class="blue">*</span> Your Name : </strong></label> <input id="name" name="name" type="text" class="validate['required','name'] textinput" /> <!-- Email --> <label for="email"><strong><span class="blue">*</span> Your E-mail : </strong></label> <input id="email" name="email" type="text" class="validate['required','email'] textinput" /> <!-- Subject --> <label for="subject"><strong><span class="blue">*</span> Your Subject : </strong></label> <input id="subject" name="subject" type="text" class="validate['required','subject'] textinput" /> <!-- Message --> <label for="msg"><strong><span class="blue">*</span> Your Message : </strong></label> <textarea id="message" name="message" type="text" class="validate['required','message'] textarea"></textarea> <!-- Spam Check --> <label for="spamcheck"><span class="blue">*</span> <acronym title="[ Spam prevention ]"><strong>Are you human?</acronym> : <span class="blue">2 + 3 = ???</span></strong></label> <input id="spamcheck" name="spamcheck" type="text" size="5" class="validate['required','spamcheck'] textinput_small" /> <br /><br /> <input type="submit" class="buttonSubmit" value="Send it!" /> <div id="stylesheetTest"></div> </form> <?php } else { error_reporting(0); if (mail($to, $subject, $msg, "From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n")) //Message sent! //It the message that will be displayed when the user click the sumbit button //You can modify the text if you want echo nl2br(" <div class=\"MsgSent\"> <h1>Congratulations!!</h1> <p>Thank you <b><?=$name;?></b>, your message is sent!<br /> I will get back to you as soon as possible.</p> </div> "); else // Display error message if the message failed to send echo " <div class=\"MsgError\"> <h1>Error!!</h1> <p>Sorry <b><?=$name;?></b>, your message failed to send. Try later!</p> </div>"; } ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
utdfederation Posted August 20, 2008 Author Share Posted August 20, 2008 it would seem i had something wrong but i have changed it to this. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <?php $whoto = $_POST['whoto']; $mails = array("your@email.com", "your@email.com", "your@email.com", "your@email.com", "your@email.com"); $mailto = $mails[$whoto]; // send the mail to //User info $name = stripslashes($_POST['name']); $email = stripslashes($_POST['email']); //The subject $subject = "WebContact "; $subject .= stripslashes($_POST['subject']); $msg = "From : $name \r\n"; $msg .= "e-Mail : $email \r\n"; $msg .= "Subject : $subject \r\n\n"; $msg .= "---Message--- \r\n".stripslashes($_POST['message'])."\r\n\n"; ?> <head> <title>Contact Us</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="css/main.css" type="text/css" media="screen" /> <meta name="description" content="Ajax Contact form using CheckForm2 and NiceForms." /> <meta name="keywords" content="php, contact form, Ajax, mootools, checkform2, niceforms, Moo Floor, class, javascript, spamcheck, badboy.ro" /> <meta name="author" content="Jeremie Tisseau" /> <link rel="stylesheet" href="js/formcheck/formcheck.css" type="text/css" media="screen" /> <script type="text/javascript" src="js/mootools.js"></script> <script type="text/javascript" src="js/formcheck/formcheck.js"></script> <script type="text/javascript"> window.addEvent('domready', function(){check = new FormCheck('third', { display : { fadeDuration : 500, errorsLocation : 1, indicateErrors : 1, showErrors : 1 } })}); </script> <link rel="stylesheet" href="js/niceform/niceforms-default.css" type="text/css" media="screen" /> <script type="text/javascript" src="js/niceform/niceforms.js"></script> </head> <body> <!-- The contact form starts here--> <?php if ($_SERVER['REQUEST_METHOD'] != 'POST'){ $self = $_SERVER['PHP_SELF']; ?> <!-- Start HTML form --> <form name="form" method="post" id="third" action="<?php echo $self;?>"> <h1>Contact Us</h1> <!-- Contact --> <label for="name"><strong><span class="blue">*</span> Please Select a Contact : </strong></label> <select name="whoto"> <option value="your@email.com">Contact1</option> <option value="your@email.com">Contact2</option> <option value="your@email.com">Contact3</option> <option value="your@email.com">Contact4</option> <option value="your@email.com">Contact5</option> </select> <!-- Name --> <label for="name"><strong><span class="blue">*</span> Your Name : </strong></label> <input id="name" name="name" type="text" class="validate['required','name'] textinput" /> <!-- Email --> <label for="email"><strong><span class="blue">*</span> Your E-mail : </strong></label> <input id="email" name="email" type="text" class="validate['required','email'] textinput" /> <!-- Subject --> <label for="subject"><strong><span class="blue">*</span> Your Subject : </strong></label> <input id="subject" name="subject" type="text" class="validate['required','subject'] textinput" /> <!-- Message --> <label for="msg"><strong><span class="blue">*</span> Your Message : </strong></label> <textarea id="message" name="message" type="text" class="validate['required','message'] textarea"></textarea> <!-- Spam Check --> <label for="spamcheck"><span class="blue">*</span> <acronym title="[ Spam prevention ]"><strong>Are you human?</acronym> : <span class="blue">2 + 3 = ???</span></strong></label> <input id="spamcheck" name="spamcheck" type="text" size="5" class="validate['required','spamcheck'] textinput_small" /> <br /><br /> <input type="submit" class="buttonSubmit" value="Send it!" /> <div id="stylesheetTest"></div> </form> <?php } else { error_reporting(0); if (mail($to, $subject, $msg, "From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n")) //Message sent! //It the message that will be displayed when the user click the sumbit button //You can modify the text if you want echo nl2br(" <div class=\"MsgSent\"> <h1>Congratulations!!</h1> <p>Thank you <b><?=$name;?></b>, your message is sent!<br /> I will get back to you as soon as possible.</p> </div> "); else // Display error message if the message failed to send echo " <div class=\"MsgError\"> <h1>Error!!</h1> <p>Sorry <b><?=$name;?></b>, your message failed to send. Try later!</p> </div>"; } ?> </body> </html> can someone please tell me if this is correct please? Quote Link to comment Share on other sites More sharing options...
Lamez Posted August 20, 2008 Share Posted August 20, 2008 very simple you are going to need to pull the five contacts, then add them into a while loop. But I do not see where you are storing your contacts. A database? Quote Link to comment Share on other sites More sharing options...
utdfederation Posted August 20, 2008 Author Share Posted August 20, 2008 storing them on this line: $mails = array("your@email.com", "your@email.com", "your@email.com", "your@email.com", "your@email.com"); thank you very much by the way for responding in my hour of need. Quote Link to comment Share on other sites More sharing options...
Lamez Posted August 21, 2008 Share Posted August 21, 2008 <?php $mails = array("1@email.com", "2@email.com", "3@email.com", "4@email.com", "5@email.com"); ?> <select name="select" id="select"> <option><?php echo $mails['0']; ?></option> <option><?php echo $mails['1']; ?></option> <option><?php echo $mails['2']; ?></option> <option><?php echo $mails['3']; ?></option> <option><?php echo $mails['4']; ?></option> </select> very simple Quote Link to comment Share on other sites More sharing options...
utdfederation Posted August 21, 2008 Author Share Posted August 21, 2008 thank you for the reply i appreciate it. it may be very simple to you but to a novice like me it is hard. Quote Link to comment Share on other sites More sharing options...
Lamez Posted August 21, 2008 Share Posted August 21, 2008 oh, no everybodys gota learn some time or another, we are all here just to help, almost more than half of my posts where questions, lol Quote Link to comment Share on other sites More sharing options...
utdfederation Posted August 21, 2008 Author Share Posted August 21, 2008 i know i know like i said i appreciate your experience on helping an old man out. however i am having a problem and this is the final part now. when i upload the file onto my server and try it out the drop-down box does not show at all so the user is unable to selct a contact. any suggestions on why this is the case? when you first launch the page you can see it for a split second then it's gone. here is the link where it is at the moment. http://www.oldburyparkwhitetigers.co.uk/contact/index.php would it be easier for you to contact me on xfire? if so my id is utdfederation would appreciate anything you can do to help solw this last part even pay for it Quote Link to comment Share on other sites More sharing options...
Lamez Posted August 21, 2008 Share Posted August 21, 2008 I added you! We can figure this out 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.