Clueless about PHP

Discussion in 'OT Technology' started by Viperous, Mar 6, 2006.

  1. Viperous

    Viperous New Member

    Joined:
    Jun 7, 2004
    Messages:
    1,361
    Likes Received:
    0
    Location:
    Cincinnati, Ohio
    Hello,
    I'm trying to adjust an application form submission script that a former gamer had written for the Guild I am. He's quit the game and we have no Idea how to contact him and I have no idea how to code with PHP.

    What I'm trying to do is make it so that if a certain "class" is selected from the drop-down list then it will send an additional e-mail (cc) to a specific person.

    The Form Object Name of the drop-down box is "Class"
    The Options are: Druid, Hunter, Mage, Priest, Rogue, Shaman, Warlock, Warrior

    The E-mails are:
    If Druid send to [email protected]
    If Hunter send to [email protected]
    If Mage send to [email protected]
    If Priest send to [email protected]
    If Rogue send to [email protected]
    If Shaman send to [email protected]
    If Warlock send to [email protected]
    If Warrior send to [email protected]

    The current PHP script is

    Code:
    <?php
    
    function ison($data) {
        if ($data == "On") {
            return "Yes";
        } else {
            return "No";
        }
    }
    
    function buildCc($data) {
        $cc = "";
        for ($i = 1; $i < count($data); $i++) {
            $cc .= $data[$i];
            if ($i < count($data)-1) {
                $cc .= ', ';
            }
        }
        return $cc;
    }
    
    if (array_key_exists('Submit', $_POST)) {
        // Email addresses to send form to
        $email = array("[email protected]", "[email protected]", "[email protected]", "[email protected]");
        
        $to = $email[0];
        $subject = 'Adversaries Application: '.$_POST['Name'].' - '.$_POST['Level'].' '.$_POST['Class'];
        $extra = 'From: [email protected]'."\r\n";
        if (count($email) > 1) {
            $extra .= 'Cc: '.buildCc($email);
        }
        
        $msg = 'Basic Info'."\n";
        $msg .= 'Name: '.$_POST['Name']."\n";
        $msg .= 'Email: '.$_POST['Email']."\n";
        $msg .= 'Class: '.$_POST['Class']."\n";
        $msg .= 'Level: '.$_POST['Level']."\n\n";
        $msg .= 'Attunement'."\n";
        $msg .= 'Onyxia: '.ison($_POST['Ony'])."\n";
        $msg .= 'Molten Core: '.ison($_POST['MC'])."\n";
        $msg .= 'Blackwing Lair: '.ison($_POST['BWL'])."\n\n";
        $msg .= 'Playing Hours'."\n";
        $msg .= 'Timezone: '.$_POST['Timezone']."\n";
        $msg .= 'Hours/Day: '.$_POST['Playtime']."\n\n";
        $msg .= 'Raid Times'."\n";
        $msg .= 'Monday 4:00-11:00: '.ison($_POST['Monday'])."\n";
        $msg .= 'Wednesday 4:00-11:00: '.ison($_POST['Wednesday'])."\n";
        $msg .= 'Thursday 4:00-11:00: '.ison($_POST['Thursday'])."\n";
        $msg .= 'Saturday 2:00+: '.ison($_POST['Saturday'])."\n";
        $msg .= 'Sunday 2:00+: '.ison($_POST['Sunday'])."\n\n";
        $msg .= 'Misc Questions'."\n\n";
        $msg .= 'Why do you want to join Adversaries?'."\n";
        $msg .= $_POST['Why']."\n\n";
        $msg .= 'What type of End Game experience do you have?'."\n";
        $msg .= $_POST['Endgame']."\n\n";
        $msg .= 'Able to use Ventrilo: '.$_POST['Ventrilo']."\n\n";
        $msg .= 'Is there anything else about you that you would like us to know?'."\n";
        $msg .= $_POST['AboutMe']."\n\n";
        $msg .= '-----------------'."\n\n";
        $msg .= 'Automated Application Submission'."\n";
        
        $msg = wordwrap($msg, 70);
        
        mail($to, $subject, $msg, $extra) or die(print_r("Error sending Application"));
        header("Location: http://www.adversaries-guild.com");
    } else {
        header("HTTP/1.0 404 Not Found");
    }
    
    ?>
    Any help with redoing the code or pointing me in a direction where I can find out the information that I need would be much apprecciated!

    Thanks
     
  2. sushi2006

    sushi2006 New Member

    Joined:
    Feb 28, 2006
    Messages:
    296
    Likes Received:
    0
    Location:
    NYC
    <select name="class">
    <option value="druid">druid</option>
    ...
    ...
    </select>

    then add something like this in php

    switch($_POST['class']) {
    case 'druid':
    $cc = 'whateveremail';
    break;
    case 'otherclass':
    $cc = 'other email';
    break;
    }

    php.net/switch for more info
     

Share This Page