Jordan Windeatt Posted April 24, 2010 Share Posted April 24, 2010 This is the first time I've actually officially asked for help with my coding. Before, I use to always Google what I wanted, and I got a fix. But this is just one problem I cannot find a fix to. Here's the scenario: I am the Webmaster for RF (a small writing community). I've got a single page for sending messages to the specific people it requires to. Currently, all e-mails are sent to me, and I pass them on. But I believe that this is a bit unprofessional, and would like to try to incorporate some IF and ELSE statements into my code. As I have no idea where to begin with PHP, I thought I'd call upon the Gurus of the 'net.... you guys, and gals! Here's the HTML document (sendmessage.html): <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" /> <html> <head> <meta name="generator" content="HTML Tidy for Linux (vers 6 November 2007), see www.w3.org" /> <meta name="description" content="Raptor Fleet is probably the fastest growing role-playing organisation on the Internet, to date! Do you stare up into the night's sky? Do you long to know what it'll be like in a few hundred years? Then Raptor Fleet is the place for you, join today! Don't delay!" /> <meta name="keywords" content="raptor fleet star trek role playing play game rpg future writting writing" /> <link rel="shortcut icon" href="images/favicon.ico" /> <title>Raptor Fleet • Send Message</title> <link rel="stylesheet" href="styles/main.css" type="text/css" /> <link rel="stylesheet" href="styles/forms.css" type="text/css" /> </head> <body class="content"> <div class="top"></div> <div class="navigation"> <a href="index.html">Home</a> <a href="commandstaff.html">Command Staff</a> <a href="taskforces.html">Task Forces</a> <a href="database.html">Database</a> <a href="applications.html">Join Us</a> <a href="http://forum.raptorfleet.co.uk/" target="_blank">Forum</a> </div> <div class="bottom"></div> <div class="banner"></div> <div class="top"></div> <div class="title"> <span class="heading">Send Message</span><br /> <span class="subheading">"The language of one is more important than the language of a thousand." - Jordan Windeatt</span> </div> <div class="main"> <table> <tr> <td width="600px"> <form method="post" action="sendmessage.php"> <table width="500" align="left" cellspacing="0" cellpadding="5"> <tr> <td width="95px" align="left" valign="top"> To: </td> <td align="left" valign="top"> <select name="to"> <option value="Command Staff" selected="Command Staff">Command Staff</option> <option value="Commander in Chief">Commander in Chief</option> <option value="Deputy Commander in Chief">Deputy Commander in Chief</option> <option value="Chief of Staff">Chief of Staff</option> <option value="Academy Commandant">Academy Commandant</option> <option value="Director of Research and Development">Director of Research and Development</option> <option value="Director of Kuro-RPG.net">Director of Kuro-RPG.net</option> <option value="Technical Support">Technical Support</option> </select> </td> </tr> <tr> <td width="95px" align="left" valign="top"> From: </td> <td align="left" valign="top"> <input type="text" name="from" size="30"> </td> </tr> <tr> <td width="95px" align="left" valign="top"> E-mail Address: </td> <td align="left" valign="top"> <input type="text" name="email" size="30"> </td> </tr> <tr> <td width="95px" align="left" valign="top"> Message: </td> <td align="right" valign="top"> <textarea name="message" rows="7"></textarea><br /> <br /> <br /> </td> </tr> <tr> <td width="95px" align="left" valign="top"> </td> <td align="center" valign="top"> <input type="reset" class="reset" value="Reset Message"> <input type="submit" class="submit" value="Submit Message"> </td> </tr> </table> </form> </td> <td width="155px" valign="top"> <object data="sidebar.html" type="text/html" width="150px" height="210px" border="0"> If you're seeing this message. It means your browser does not support 'object' tags.<br /> <br /> Please use <a href="sidebar/news.html">this</a> link to view the page instead. </object> </td> </tr> </table> </div> <div class="credits"> <br /> <a href="credits.html">Credits</a>, website created by <a href="mailto:[email protected]">Jordan Windeatt</a>. </div> <div class="bottom"></div> </body> </html> ... and here's the PHP document (sendmessage.php) <?php /* Subject and E-mail Variables */ $emailSubject = 'Raptor Fleet - Send Message'; $webMaster = '[email protected] , [email protected]'; /* Gathering Data Variables */ $toField = $_POST['to']; $fromField = $_POST['from']; $emailField = $_POST['email']; $messageField = $_POST['message']; $body = <<<EOD <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <html><font face="Tahoma"> <center><a href="http://jordanwindeatt.co.uk/" target="_blank"><img src="http://raptorfleet.co.uk/images/email/header.png" border="0"></a></center><br /> <br /> <strong>To:</strong> $to <br /> <strong>From:</strong> $from <br /> <strong>E-mail:</strong> $email <br /> <strong>Message:</strong> $message <br /> </font></html> EOD; $headers = "From: $email\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); /* Results rendered as HTML */ $theResults = <<<EOD <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" /> <html> <head> <meta name="generator" content="HTML Tidy for Linux (vers 6 November 2007), see www.w3.org" /> <meta name="description" content="Raptor Fleet is probably the fastest growing role-playing organisation on the Internet, to date! Do you stare up into the night's sky? Do you long to know what it'll be like in a few hundred years? Then Raptor Fleet is the place for you, join today! Don't delay!" /> <meta name="keywords" content="raptor fleet star trek role playing play game rpg future writting writing" /> <link rel="shortcut icon" href="images/favicon.ico" /> <title>Raptor Fleet • Send Message</title> <link rel="stylesheet" href="styles/main.css" type="text/css" /> <link rel="stylesheet" href="styles/forms.css" type="text/css" /> </head> <body class="content"> <div class="top"></div> <div class="navigation"> <a href="home.html">Home</a> <a href="commandstaff.html">Command Staff</a> <a href="taskforces.html">Task Forces</a> <a href="database.html">Database</a> <a href="applications.html">Join Us</a> <a href="http://forum.raptorfleet.co.uk/" target="_blank">Forum</a> </div> <div class="bottom"></div> <div class="banner"></div> <div class="top"></div> <div class="title"> <span class="heading">Send Message</span><br /> <span class="subheading">"The language of one is more important than the language of a thousand." - Jordan Windeatt</span> </div> <div class="main"> <table> <tr> <td width="600px" valign="top"> Thank you for your message, please expect a reply within the next forty-eight hours. Otherwise, feel free to contact <a href="mailto:[email protected]">Technical Support</a>, thank you. </td> <td width="155px" valign="top"> <object data="sidebar.html" type="text/html" width="150px" height="210px" border="0"> If you're seeing this message. It means your browser does not support 'object' tags.<br /> <br /> Please use <a href="sidebar/news.html">this</a> link to view the page instead. </object> </td> </tr> </table> </div> <div class="credits"> <br /> <a href="credits.html">Credits</a>, website created by <a href="mailto:[email protected]">Jordan Windeatt</a>. </div> <div class="bottom"></div> </body> </html> EOD; echo "$theResults"; ?> I'd like it so that for each option there is in the drop-down menu in the .html file, there is an IF/ELSE statement - forwarding to a different e-mail. For the purposes of this, could you just use '[email protected]', '[email protected]' etc...? Thanks for the help... Link to comment https://forums.phpfreaks.com/topic/199600-e-mail-if-and-else-statements/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.