Hello!
I'm trying to have a contact form that includes a drop down selection menu of about 5 different departments and once that selection has been made, after the form has been filled out - all the necessary information is then emailed to that selected department.
View the form here:
http://incentivo.dreamhosters.com/contact/contactNEW.html
The very first drop down should have multiple options but I've run into some issues and could use some guidance.
here is the PHP:
<?php
header("Location: /contact/thankyou.html");
if(isset($_POST['submit']))
{
$departments = array();
// $departments[] = array('Department Name', 'department@email.address');
$departments[] = array('Finance Department', 'email@domain.com');
$departments[] = array('Main Office', 'email@domain.com');
$departments[] = array('Billing', 'email@domain.com');
$departments[] = array('Other', 'email@domain.com');
$to = "email@domain.com";
if (is_numeric($_REQUEST['questiondropdown']) AND $_REQUEST['questiondropdown'] != '-1' AND array_key_exists($_REQUEST['questiondropdown'], $departments))
{
$to = $departments[$_REQUEST['questiondropdown']][1];
}
$subject = "LoHi Scooters Contact Form";
$first_name = $_POST['firstname'];
$last_name = $_POST['lastname'];
$contact_email = $_POST['emailaddress'];
$phone_1 = $_POST['phone1'];
$address_1 = $_POST['address1'];
$address_2 = $_POST['address2'];
$contact_city = $_POST['city'];
$contact_state = $_POST['state'];
$contact_zipcode = $_POST['zipcode'];
$contact_question = $_POST['questiondropdown'];
$contact_subject = $_POST['subject'];
$contact_message = $_POST['message'];
$preferred_checkbox = $_POST['check[]'];
foreach($_POST['check'] as $value)
{
$check_msg .= "Preferred Method of Contact: $value\n";
}
$body = "First Name: $first_name\nLast Name: $last_name\nE-Mail: $contact_email\n\nPhone: $phone_1\nAddress 1: $address_1\nAddress 2: $address_2\nCity: $contact_city\nState: $contact_state\nZip Code: $contact_zipcode\n\nMy Question is Regarding: $contact_question\nSubject: $contact_subject\n$check_msg \nMessage: $contact_message\n";
echo "Data has been submitted to $to!";
mail($to, $subject, $body);
}
else
{
echo "Please use the form to email us.";
}
?>
At the very top there is a header("Location: /contact/thankyou.html"); that redirects to the thankyou page. Could this be causing me some problems?
And for what it's worth...Here is the HTML:
<!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">
<head>
<title>Associação Brasileira Incentivo - Contato</title>
<link media="screen" type="text/css" rel="stylesheet" href="/resources/css/homepage.css"/>
<link media="screen" type="text/css" rel="stylesheet" href="/resources/css/diagram.css"/>
<link media="screen" type="text/css" rel="stylesheet" href="/resources/css/view.css"/>
<script type="text/javascript" src="/resources/scripts/hover.js"></script>
</head>
<body id="quem-somos">
<div id="banner">
<div id="nav-global-container">
<ul id="nav-global">
<li id="nav-contact"><a href="/contact/">Contato</a></li><li>|</li>
<!-- <li id="nav-history"><a href="/historia/">Historiá</a></li><li>|</li> -->
<li id="nav-background"><a href="/quem-somos/">Quem somos</a></li><li>|</li>
<li id="nav-home"><a href="/index.html">Home</a></li>
</ul>
</div>
</div>
<div id="container">
<div id="header">
<h1 id="logo"><a href="/index.html"><img alt="Incentivo" src="/resources/images/logo.png"/></a></h1>
<div id="nav-sub-container">
<ul id="nav-sub">
<li id="first"><div>Programas</div>
<ul>
<li><a href="/bolsa-de-estudo/">Bolsa de Estudo</a></li>
<li><a href="/financas-pessoais/">Finanças Pessoais</a></li>
<li><a href="/preparacao-para-mba/">Preparação para MBA</a></li>
</ul>
</li>
<li><div>Filosofia</div>
<ul>
<li><a href="/passar-adiante/">Passar adiante</a></li>
<li><a href="/successo/">Histórias de successo</a></li>
<li><a href="/voluntarios/">Voluntários</a></li>
</ul>
</li>
<!--
<li id="last"><div>Forums</div>
<ul>
<li><a href="/forums/">Bolsa</a></li>
<li><a href="/forums/">Financas</a></li>
<li><a href="/forums/">MBA</a></li>
</ul>
</li>
-->
</ul>
</div>
</div>
<div id="billboard"><h2>Incentivo</h2></div>
<div id="columnwrap">
<div id="content-main">
<h1>Contato</h1>
<p>Seus comentários e perguntas são importantes para nos. Favor preencher as informações a seguir para que possamos responder a suas perguntas. Antes de enviar um email, favor verificar se a sua pergunta já foi respondida na lista de perguntas frequentes.</p>
<p>*Campos com asterisco são de preenchimento obrigatório </p>
<h2>Perguntas Frequentes</h2>
<li><a href="/bolsa-de-estudo/faq/">Bolsas de Estudo</a></li>
<li><a href="/financas-pessoais/faq/">Finanças Pessoais</a></li>
<li><a href="/preparacao-para-mba/faq/">Preparação para MBA</a></li>
<form method="post" action="/resources/scripts/mailer.php">
<table width="465" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="465" height="40" align="left" valign="top" class="darkGreyLeftPanel"><p>Classificação da Mensagem*<br />
<select name="questiondropdown" size="1" class="contactRightPanel">
<option value="-1" selected="selected">Selecione...</option>
<?php
foreach ($departments as $id => $info)
{
print('<option value="');
print($id);
print('">');
print($info[0]);
print('</option>');
print("\n");
}
?>
</select></p>
<p>Assunto*<br />
<input name="subject" type="text" class="contactRightPanel" size="25" />
</p>
<p>Mensagem | Comentários*<br />
<textarea name="message" cols="75" rows="3" class="contactRightPanel"></textarea>
</p>
<p>Dados Pessoais</p>
<table width="465" height="40" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="182" height="40" align="left" valign="top" class="darkGreyLeftPanel"><p>Nome*
<input name="firstname" type="text" class="contactRightPanel" size="25" />
</p></td>
<td width="293" align="left" valign="top"><p> Sobrenome*<br />
<input name="lastname" type="text" class="contactRightPanel" size="25" />
</p></td>
</tr>
</table>
<br />
Endereço de E-mail*<br />
<input name="emailaddress" type="text" class="contactRightPanel" size="25" />
</p>
<p> Confirme o Endereço de E-mail*<br />
<input name="emailaddress" type="text" class="contactRightPanel" size="25" />
</p>
<p>
<input type="submit" value="Submit" name="submit" /></td>
</tr></table>
</form>
</div>
<div class="sidebar" id="content-related">
<h2>Programas da Incentivo</h2>
<ul>
<li><a href="/bolsa-de-estudo/">Bolsas de Estudo</a></li>
<li><a href="/financas-pessoais/">Finanças Pessoais</a></li>
<li><a href="/preparacao-para-mba/">Preparação para MBA</a></li>
</ul>
<h2>Filosofia</h2>
<ul>
<li><a href="/passar-adiante/">Passar adiante</a></li>
<li><a href="/successo/">Histórias de successo</a></li>
<li><a href="/voluntarios/">Voluntários</a></li>
</ul>
</div>
</div>
</div>
<div id="footer">
<p>
© 2005-2007 Associação Brasileira Incentivo. Todos os direitos
reservados.
</p>
</div>
</div>
</body>
</html>
Thanks in advance!
Brian