PHP email form multiple select

Posted by Justin Goodman on Stack Overflow See other posts from Stack Overflow or by Justin Goodman
Published on 2010-06-05T19:21:18Z Indexed on 2010/06/05 19:32 UTC
Read the original article Hit count: 302

Filed under:
|
|
|

I'm trying to set up a simple PHP contact form for a website and I need some help modifying the PHP to list multiple items from a select menu and would appreciate the help. I'm a graphic designer, not a developer, so a lot of this is way over my head. This is the problem area here:

    <label for="Events[]">Which Event(s) Will You Be Attending?</label>
   <div class="input-bg">
              <select name="Events[]" size="6" multiple="MULTIPLE" class="required" id="Events[]">
                <option value="Wednesday">Portfolio Show June 16</option>
                <option value="Thursday">Portfolio Show June 17</option>
                <option value="Saturday">Graduation Ceremony</option>
                <option value="Saturday Eve">Graduation Party</option>
                <option value="Not Sure">Not Sure</option>
                <option value="Not Coming">Not Coming</option>
              </select>
      </div>

And here's the PHP:

    <?php

// CHANGE THE VARIABLES BELOW

$EmailFrom = "[email protected]";
$EmailTo = "[email protected]";
$Subject = "Graduation RSVP";

$Name = Trim(stripslashes($_POST['Name'])); 
$Email = Trim(stripslashes($_POST['Email'])); 
$Guests = Trim(stripslashes($_POST['Guests'])); 
$Events = Trim(stripslashes($_POST['Events'])); 

// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Guests: ";
$Body .= $Guests;
$Body .= "\n";
$Body .= "Events: ";
$Body .= $Events;
$Body .= "\n";

// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page
// CHANGE THE URL BELOW TO YOUR "THANK YOU" PAGE
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=http://justgooddesign.net/graduation\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=http://justgooddesign.net/graduation/error.html\">";
}
?>

Any help really is appreciated!

© Stack Overflow or respective owner

Related posts about php

Related posts about email