Hello. I'm a newbie, and have a question. I am making a contact form, and want to be able to have a drop down menu on the form for the user to select what department they want to email. Here's the code i have right now:
<?php
//Declare the variables
$recipient = $contact;
$subject = "Contact Form submission";
$message = $comments;
$from = $email;
//Contents of form
$contact = $POST['contact'];
$sales = "sales@myserver.com"
$parts = "parts@myserver.com"
$service = "service@myserver.com"
$website = "webmaster@myserver.com"
$name =$POST['name'];
$email =$POST['email'];
$phone =$POST['phone'];
$comments =$_POST['comments'];
//mail() function sends the mail
mail("To: $contact",$subject,"Name: $name\r\nPhone: $phone\r\nQuestion: $comments","From: $email");
?>
here's my html form:
<form action=contactform.php method=post>
<table width="90%" border="0" align="center">
<tr>
<td width="19%">Contact: </td>
<td width="81%">
<select name="contact">
<option value="sales" selected>Sales Department</option>
<option value="parts">Parts / Accessories</option>
<option value="service">Service Department</option>
<option value="website">Website / Design</option>
</select>
</td>
</tr>
<tr>
<td width="19%" height="19">Name: </td>
<td width="81%" height="19">
<input type="text" name="name">
</td>
</tr>
<tr>
<td width="19%">Email:</td>
<td width="81%">
<input type="text" name="email">
</td>
</tr>
<tr>
<td width="19%">Phone:</td>
<td width="81%">
<input type="text" name="phone" value="( )">
</td>
</tr>
<tr>
<td width="19%">Message:</td>
<td width="81%">
<textarea name="comments" rows="3"></textarea>
</td>
</tr>
<tr>
<td width="19%">&</td>
<td width="81%">
<input type="submit" name="Submit" value="Send">
</td>
</tr>
</table>
</form>
the variables called $sales, $parts, etc. under the contacts are the variables for the different email addresses depending on what is selected. I named the values in the drop down box those variables (ex. sales, parts, etc.) is that correct?
Should I use an array function with those different variables?
I have tried many things but can't get it to work. Thanks a lot for your help.
Thanks.
Nik