Hi. I am trying to create a form where the user can choose a recipient from a drop down menu. I am extremely new to php, and have managed to piece together some code from some tutorials:
The code for the form:
<form action="send_form.php" method="post">
Name: <input type="text" name="name"><br><br>
Email (optional): <input type="text" name="email"><br><br>
Choose a Recipient:
<select name="recipient">
<option>(select one)
<option name="person1">person1
<option name="person2">person2
</select><br><br>
Message:
<textarea name="message" rows="10" cols="10"></textarea><br><br>
<input type="submit" name="submit" value="Send">
<input type="reset" value="Reset">
</form>
And the code for send_form.php:
<?php
{
if($_POST['recipient'] == "person1")
{
$sendto = "person1@place.com";
$recipient = $_POST['recipient'];
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
mail( "$sendto", "Feedback From Site",
"Name: $name\n\n$message",
"From: $name" );
}
else if($_POST['recipient'] == "person2")
{
$sendto = "person2@place.com";
$recipient = $_POST['recipient'];
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
mail("$sendto", "Feedback From Site",
"Name: $name\n\n$message",
"From: $name" );
}
?>
How can I fix or re-write this code to make it work? Thanks!