Member Avatar for TheFearful

Hey everyone, I decided to do a lot of echos to make a letter for different selections based off the user. Everything works well except that when the user selects one of the options, two different letters are shown on the page and it's only for one of the options. Would anyone know why this would be the case?

function greeting()
{
    echo $GLOBALS['Date'];
    echo "<br><br> Name: ". $GLOBALS['FirstName']. " ". $GLOBALS['LastName'];
    echo "<br> Address: ". $GLOBALS['Address']. ", ". $GLOBALS['City']. ", ". $GLOBALS['State']. " ". $GLOBALS['Zip'];
    echo "<br><br> RE: Account# ". $GLOBALS['AccountNumber'];
    echo "<br><br> Dear ". $GLOBALS['Gender']. " ". $GLOBALS['LastName']. ",";
    echo "<br><br> Thank you for choosing Company, a leader in Internet, data, voice and video services. As the";
    echo "<br> Sales Engineer who will coordinate the installation of your services, I'd like to share some";
    echo "<br> important information.";
    echo "<br><br> My direct telephone number is 1.800.555.5555 ext. ".$GLOBALS['Extension']. ". In the event that you need an";
    echo "<br> alternate contact, my direct supervisor is Bob Bob and he can be reached at 1.800.555.5555";
    echo "<br> ext. 5555.";
    echo "<br><br> You will receive a telephone call from one of our cable partners within the next two weeks to";
    echo "<br> schedule an installation date. If you do not receive a call within that time period, please let me";
    echo "<br> know.";
    echo "<br><br> Once your service has been installed, the contact number for questions or concerns about sales";
    echo "<br> or billing is 1.800.555.5555 ext. 5555. For technical questions or problems with your service,";
    echo "<br> contact our Technical Support at 1.800.555.5555 ext. 5555.";
    echo "<br><br> Please keep us in mind for all of your data and Internet needs, including high-speed cable";
    echo "<br> modems, dedicated connections, and network security. In addition, Company I.T. Services is";
    echo "<br> ready to help with everything from designing and installing a network to basic software";
    echo "<br> purchases, computer maintenance, repair, security and more. For additional information about";
    echo "<br> these and other beneficial services available to you as a PenTeleData customer, call or visit us";
    echo "<br> online at www.company.net.";
    echo "<br><br> Thank you for your business and continued support.";
    echo "<br><br> Sincerely,";
    echo "<br><br>". $GLOBALS['EFirstName']. " ". $GLOBALS['ELastName'];
    echo "<br> Sales Engineer";
    echo "<br> Company";
}

function dedicated()
{       
    //The contents of the letter
    echo $GLOBALS['Date'];
    echo "<br><br> Name: ". $GLOBALS['FirstName']. " ". $GLOBALS['LastName'];
    echo "<br> Address: ". $GLOBALS['Address']. ", ". $GLOBALS['City']. ", ". $GLOBALS['State']. " ". $GLOBALS['Zip'];
    echo "<br><br> RE: Account# ". $GLOBALS['AccountNumber'];
    echo "<br><br> Dear ". $GLOBALS['Gender']. " ". $GLOBALS['LastName']. ",";
    echo "<br><br> Thank you for choosing Company, a leader in Internet, data, voice and video services. As the";
    echo "<br> Sales Engineer who will coordinate the installation of your services, I'd like to share some";
    echo "<br> important information.";
    echo "<br><br> My direct telephone number is 1.800.555.5555 ext. ".$GLOBALS['Extension']. ". Please feel free to contact me with";
    echo "<br> any questions or concerns about your set-up. In the event that you need an alternate contact,";
    echo "<br> my direct supervisor is Bob Bob and he can be reached at 1.800.555.5555 ext. 5555.";
    echo "<br><br> Once your service has been installed, the contact number for questions or concerns about sales";
    echo "<br> or billing is 1.800.555.5555 ext. 5555. For technical questions or problems with your service,";
    echo "<br> contact our Network Control Center at 1.877.555-5555.";
    echo "<br><br> Please keep us in mind for all of your data and Internet needs, including high-speed cable";
    echo "<br> modems, dedicated connections, and network security. In addition, Company I.T. Services is";
    echo "<br> ready to help with everything from designing and installing a network to basic software";
    echo "<br> purchases, computer maintenance, repair, security and more. For additional information about";
    echo "<br> these and other beneficial services available to you as a Company customer, call or visit us";
    echo "<br> online at www.company.net.";
    echo "<br><br> Thank you for your business and continued support.";
    echo "<br><br> Sincerely,";
    echo "<br><br>". $GLOBALS['EFirstName']. " ". $GLOBALS['ELastName'];
    echo "<br> Sales Engineer";
    echo "<br> Company";
}

//Depending on what button was pressed on the last page
//these if statements will either preview the letter for us
//or to email the sales engineer and update the ticket.
if(isset($_POST['previewLetter']))
{
    if(isset($_POST['letter']))
    {

        if($_POST['letter'] == "greetingDedicated")
        {
            dedicated();
        }
        else if($_POST['letter'] == 'greetingCable');
        {
            greeting();
        }       
    }
}
Member Avatar for TheFearful

Pretty much, you can look at the last 10+ lines of code. Those are where the calls to the fucntions are on and I don't know why one of the functions gets called all the time no matter what.

Member Avatar for TheFearful

Now, only one function is being called all the time and I don't know why. I'll give the conditions for the function to be called.

if(isset($_POST['previewLetter']))
{
    if(isset($_POST['letter']))
    {

        if($_POST['letter'] == 'greetingDedicated')
        {
            dedicated();
        }
        if($_POST['letter'] == 'greetingCable');
        {
            greeting();
        }
    }
}

From the previous page for my php files, I have these options that the user can choose from

<select type="text" name="letter">
                <option name="LetterList">Drop down list</option>
                <option name="greetingDedicated">Sales Greeting Dedicated</option>
                <option name="greetingCable">Sales Greeting Cable</option>
                <option name="installSite">Service Installation For Site</option>
            </select>

Would you happen to know why the greeting() function is always being called?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.