4 Replies - 485 Views - Last Post: 26 September 2012 - 10:15 PM Rate Topic: -----

#1 Skunny  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 12-March 12

Trouble with form submit creating another form that needs submitted

Posted 26 September 2012 - 09:01 AM

Heres what needs to happen in the code below:

A person enters name and chooses a state then submits the form.
A description of the state comes up and gives you another form to choose a city in that state and asks you to submit.
After you click the city submit it should pop up with a description of that city.

What happens is it gets stuck in an infinite loop after I try to submit the city.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
        <title>State Visit Form</title>
    
        <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
</head>
    
    <body>
        
        <div style="text-align:center;" id="header">
            <h1>State Visit Form</h1>
        </div>
        
        <hr/>
        
        <div id="content">
            
        <table style="border:1px; width:100%; height:100%">
            <tr align="center">
                <td align="center"> <h2> State Visit Form </h2></td>
                <td align="center"> <h2> You Entered: </h2></td>
            </tr>
                    
            <tr align="center">
                <td style="width:50%; height:100%; overflow:auto; padding:4px; border:1px solid black;">
                    
                <form id='stateForm' method='post' action=''>
                    <p>
                        Name:
                        <input type='text' name='formName' value="<?php echo $_POST['formName']?>"/>
                    </p>
                    <p>
                        Where would you like to visit?:
                        <select name="formState">
                            <option value="">Select One:</option>
                            <option value="California">California</option>
                            <option value="Florida">Florida</option>
                            <option value="Hawaii">Hawaii</option>
                            <option value="Maine">Maine</option>
                            <option value="Texas">Texas</option>
                        </select>
                    </p>
                    <p>
                        <input type='submit' name='formSubmit' value='Submit' /> <input type="reset" value="Start Over"/>
                    </p>
                </form>
                    
                </td>
        
                <td align="center">
                                  
                        <?php
                            // Program to display info based on state selection.
                            $varName = $_POST['formName'];
                            $varState = $_POST['formState'];
                                
                            function stateDescription()
                            {
                                $errorMessage = "";
                                global $varName;
                                global $varState;
                                
                                //Check if name is entered.
                                if($varName == '')
                                {
                                    $errorMessage .= "<p>Error!: You forgot to enter a Name!</p>";
                                    echo $errorMessage;
                                } // End of Check Name. 
                                                               
                                //Check if state is selected.
                                if($varState == '') 
                                {
                                    $errorMessage .= "<p>Error!: You forgot to select a state!</p>";
                                    echo $errorMessage;
                                } // End of Check State.
                                
                                //if california is selected.
                                elseif($varState == 'California')
                                {
                                    echo "<p>California's diverse geography ranges from the Pacific Coast in the west, to the Sierra Nevada mountains in the east – from the Redwood–Douglas-fir forests of the northwest, to the Mojave Desert areas in the southeast. The center of the state is dominated by Central Valley, a major agricultural area. California contains both the highest and lowest points in the contiguous United States (Mount Whitney and Death Valley), and has the 3rd longest coastline of all states (after Alaska and Florida). Earthquakes are a common occurrence due to the state's location along the Pacific Ring of Fire: about 37,000 are recorded annually.";
                                    echo "<br/><br/>";
                                    echo "Notible Cities:"; 
                                    echo "<form id='cityForm' method='post' action=''>
                                            <p>
                                                Choose One:
                                                <select name='formCity'>
                                                    <option value=''>Select One:</option>
                                                    <option value='sanfrancisco'>San Francisco</option>
                                                    <option value='sacramento'>Sacramento</option>
                                                    <option value='lasangeles'>Las Angeles</option>   
                                                </select>
                                            </p>
                                            <p>
                                                <input type='submit' name='formSubmit2' value='Submit' /> <input type='reset' value='Start Over'/>
                                            </p>
                                         </form>";  
                                } // end if california.
                                
                                //if florida is selected.
                                elseif($varState == 'Florida')
                                {
                                    echo "Much of Florida is situated on a peninsula between the Gulf of Mexico, the Atlantic Ocean, and the Straits of Florida. Its geography is marked by a coastline, by the omnipresence of water and the threat of hurricanes. Florida has the longest coastline in the contiguous United States, encompassing approximately 1,350 miles (2,170 km), and is the only state to border both the Gulf of Mexico and the Atlantic Ocean. Much of the state is at or near sea level and its terrain is characterized by sedimentary soils. The climate varies from subtropical in the north to tropical in the south. Its symbolic animals like the American alligator, Florida panther and the manatee, can be found in the Everglades, one of the most famous national parks in the world.";
                                    echo "<br/><br/>";
                                    echo "Notible Cities:"; 
                                    echo "<form id='cityForm' method='post' action=''>
                                            <p>
                                                Choose One:
                                                <select name='formCity'>
                                                    <option value=''>Select One:</option>
                                                    <option value='orlando'>Orlando</option>
                                                    <option value='miami'>Miami</option>
                                                    <option value='keywest'>Key West</option>   
                                                </select>
                                            </p>
                                            <p>
                                                <input type='submit' name='formSubmit2' value='Submit' /> <input type='reset' value='Start Over'/>
                                            </p>
                                         </form>";  
                                } // end if florida.
                                
                                //if hawaii is selected.
                                elseif($varState == 'Hawaii')
                                {
                                    echo "Hawaii’s diverse natural scenery, warm tropical climate, abundance of public beaches and oceanic surrounding, and active volcanoes make it a popular destination for tourists, surfers, biologists, and volcanologists alike. Due to its mid-Pacific location, Hawaii has many North American and Asian influences along with its own vibrant native culture. Hawaii has over a million permanent residents along with many visitors and U.S. military personnel. Its capital is Honolulu on the island of Oʻahu.";
                                    echo "<br/><br/>";
                                    echo "Notible Cities:"; 
                                    echo "<form id='cityForm' method='post' action=''>
                                            <p>
                                                Choose One:
                                                <select name='formCity'>
                                                    <option value=''>Select One:</option>
                                                    <option value='honolulu'>Honolulu</option>
                                                    <option value='kihei'>Kihei</option>
                                                    <option value='hilo'>Hilo</option>   
                                                </select>
                                            </p>
                                            <p>
                                                <input type='submit' name='formSubmit2' value='Submit' /> <input type='reset' value='Start Over'/>
                                            </p>
                                         </form>";  
                                } // end if hawaii.
                                
                                //if maine is selected.
                                elseif($varState == 'Maine')
                                {
                                    echo "For thousands of years, indigenous peoples were the only inhabitants of the territory that is now Maine. At the time of European encounter, several Algonquian-speaking peoples inhabited the area. The first European settlement in Maine was by the French in 1604 on Saint Croix Island, by Pierre Dugua, Sieur de Mons. The first English settlement in Maine, the short-lived Popham Colony, was established by the Plymouth Company in 1607. A number of English settlements were established along the coast of Maine in the 1620s, although the rugged climate, deprivations, and conflict with the local peoples caused many to fail over the years.";
                                    echo "<br/><br/>";
                                    echo "Notible Cities:"; 
                                    echo "<form id='cityForm' method='post' action=''>
                                            <p>
                                                Choose One:
                                                <select name='formCity'>
                                                    <option value=''>Select One:</option>
                                                    <option value='bangor'>Bangor</option>
                                                    <option value='rockland'>Rockland</option>
                                                    <option value='portland'>Portland</option>   
                                                </select>
                                            </p>
                                            <p>
                                                <input type='submit' name='formSubmit2' value='Submit' /> <input type='reset' value='Start Over'/>
                                            </p>
                                         </form>";  
                                } // end if maine.
                                
                                //if texas is selected.
                                elseif($varState == 'Texas')
                                {
                                    echo "Due to its size and geologic features such as the Balcones Fault, Texas contains diverse landscapes that resemble both the American South and Southwest. Although Texas is popularly associated with the Southwestern deserts, less than 10% of the land area is desert. Most of the population centers are located in areas of former prairies, grasslands, forests, and the coastline. Traveling from east to west, one can observe terrain that ranges from coastal swamps and piney woods, to rolling plains and rugged hills, and finally the desert and mountains of the Big Bend.";
                                    echo "<br/><br/>";
                                    echo "Notible Cities:"; 
                                    echo "<form id='cityForm' method='post' action=''>
                                            <p>
                                                Choose One:
                                                <select name='formCity'>
                                                    <option value=''>Select One:</option>
                                                    <option value='austin'>Austin</option>
                                                    <option value='houston'>Houston</option>
                                                    <option value='dallas'>Dallas</option>   
                                                </select>
                                            </p>
                                            <p>
                                                <input type='submit' name='formSubmit2' value='Submit' /> <input type='reset' value='Start Over'/>
                                            </p>
                                         </form>";  
                                } // end if texas.     
                            }
                        ?>
                        <?php
                            // Print if form is set.
                            if(isset($_POST['formSubmit'])) 
                            {    
                                echo "<p><strong>Name: </strong> " . $varName . "</p>" . "\n";
                                echo "<p><strong>Chosen State: </strong> " . $varState . "</p>" . "\n";
                                stateDescription();
                            } // end of error checking and description if statements.
                        ?>
                    
                        <?php
                            
                            $varCity = $_POST('formCity');
                            // Program to display info based on city selection.
                            function cityDescription()
                            {
                                $errorMessage = "";
                                global $varCity;
      
                                //Check if a city is entered.
                                if($varCity == '') 
                                {
                                    $errorMessage .= "<p>Error!: You forgot to select a city!</p>";
                                    echo $errorMessage;
                                } // End of Check State.
                                //if california is selected.
                                
                                //if san fran is selected.
                                elseif($varCity == 'San Francisco')
                                {
                                    echo "<br/>";
                                    echo "<p>Today, San Francisco is one of the top tourist destinations in the world, ranking 35th out of the 100 most visited cities worldwide, and is renowned for its cool summers, fog, steep rolling hills, eclectic mix of architecture, and landmarks including the Golden Gate Bridge, cable cars, Alcatraz Island and its former prison, and its Chinatown.</p>";
                                    echo "<br/>";
                                } // end of san fran.
                                
                                // if sacramento is selected.
                                elseif($varCity == 'sacramento')
                                {
                                    echo "<br/>";
                                    echo "<p>Sacramento is the capital city of the U.S. state of California and the county seat of Sacramento County. It is located at the confluence of the Sacramento River and the American River in the northern portion of California's expansive Central Valley.</p>";
                                    echo "<br/>";
                                } // end of sacramento.
                                
                                // if las angeles is selected.
                                elseif($varCity == 'lasangeles')
                                {
                                    echo "<br/>";
                                    echo "<p>Nicknamed the City of Angels, Los Angeles is a leading world center of business, international trade, entertainment, culture, media, fashion, science, sports, technology, and education, and has been ranked the third richest city and fifth most powerful and influential city in the world. The city is home to renowned institutions covering a broad range of professional and cultural fields and is one of the most substantial economic engines within the United States.</p>";
                                    echo "<br/>";
                                }//end of las angeles.
                                
                                //if orlando is selected.
                                elseif($varCity == 'orlando')
                                {
                                    echo "<br/>";
                                    echo "<p>Orlando is nicknamed 'The City Beautiful' and its symbol is the fountain at Lake Eola. The current mayor is Buddy Dyer. The city is also sometimes nicknamed, 'The Theme Park Capital of the World', as it is best known for the Walt Disney World Resort (located approximately 21 miles (34 km) southwest of Downtown Orlando in Lake Buena Vista), founded by the Walt Disney Company in 1971, the Universal Orlando Resort (which consists of two parks, Universal Studios Florida and Islands of Adventure, as well as other attractions, including City Walk), SeaWorld, Gatorland, and Wet 'n Wild Water Park.</p>";
                                    echo "<br/>";
                                }//end of orlando.
                                
                                //if miami is selected.
                                elseif($varCity == 'miami')
                                {
                                    echo "<br/>";
                                    echo "<p>Miami is a major center and a leader in finance, commerce, culture, media, entertainment, the arts, and international trade. In 2010, Miami was classified as a Alpha- World City in the World Cities Study Group’s inventory. In 2010, Miami ranked seventh in the United States in terms of finance, commerce, culture, entertainment, fashion, education, and other sectors. It ranked thirty-third among global cities.</p>";
                                    echo "<br/>";
                                }//end of miami.
                                
                                //if key west is selected.
                                elseif($varCity == 'keywest')
                                {
                                    echo "<br/>";
                                    echo "<p>Key West is a city in Monroe County, Florida, United States. The city encompasses the island of Key West, the part of Stock Island north of U.S. 1 (the Overseas Highway) (east), Sigsbee Park (north, originally known as Dredgers Key), Fleming Key (north), and Sunset Key (west, originally known as Tank Island). Both Fleming Key and Sigsbee Park are part of Naval Air Station Key West and are inaccessible by civilians. Key West is the county seat of Monroe County. Key West is the southernmost city in the Continental United States.</p>";
                                    echo "<br/>";
                                }//end of key west.
                                
                                //if honolulu is selected.
                                elseif($varCity == 'honolulu')
                                {
                                    echo "<br/>";
                                    echo "<p>In the Hawaiian language, Honolulu means 'sheltered bay' or 'place of shelter'. The old name is said to be Kou, a district roughly encompassing the area from Nuuanu Avenue to Alakea Street and from Hotel Street to Queen Street which is the heart of the present downtown district. The city has been the capital of the Hawaiian islands since 1845 and gained historical recognition following the Japanese attack on Pearl Harbor near the city on December 7, 1941.</p>";
                                    echo "<br/>";
                                }// end honolulu.
                                
                                // if kihei is selected.
                                elseif($varCity == 'kihei')
                                {
                                    echo "<br/>";
                                    echo "<p>According to the United States Census Bureau, the CDP has a total area of 11.7 square miles (30.2 km2), of which 9.3 square miles (24.0 km2) is land and 2.4 square miles (6.2 km2), or 20.44%, is water. It is considered to be the South Side of Maui, located on the leeward side of Haleakala. The climate is arid, receiving no more than 10 inches (250 mm) of rain per year.</p>";
                                    echo "<br/>";
                                }// end of kihei.
                                
                                //if hilo is selected.
                                elseif($varCity == 'hilo')
                                {
                                    echo "<br/>";
                                    echo "<p>Hilo is the county seat of the County of Hawaii and is located in the District of South Hilo. The town overlooks Hilo Bay, situated upon two shield volcanoes; Mauna Loa, an active volcano, and Mauna Kea, a dormant volcano upon which are sited some of the world's most important ground-based astronomical observatories.</p>";
                                    echo "<br/>";
                                }//end of hilo.
                                
                                //if bangor is selected.
                                elseif($varCity == 'bangor')
                                {
                                    echo "<br/>";
                                    echo "<p>Bangor is a city in and the county seat of Penobscot County, Maine, United States, and the major commercial and cultural center for eastern and northern Maine. It is the principal city of the Bangor, Maine Metropolitan Statistical Area, which encompasses all of Penobscot County.</p>";
                                    echo "<br/>";
                                }//end of bangor.
                                
                                //if rockland is selected.
                                elseif($varCity == 'rockland')
                                {
                                    echo "<br/>";
                                    echo "<p>Rockland is a city in Knox County, Maine, in the United States. As of the 2010 census, the city population was 7,297. It is the county seat of Knox County. The city is a popular tourist destination. It is a departure point for the Maine State Ferry Service to the islands of Penobscot Bay: Vinalhaven, North Haven and Matinicus.</p>";
                                    echo "<br/>";
                                }//end of rockland.
                                
                                //if portland is selected.
                                elseif($varCity == 'portland')
                                {
                                    echo "<br/>";
                                    echo "<p>Tourists visit Portland's historic Old Port district along Portland Harbor, at the mouth of the Fore River and part of Casco Bay, and the Arts District, which runs along Congress Street in the center of the city. Portland Head Light is located in nearby Cape Elizabeth and marks the entrance to Portland Harbor.</p>";
                                    echo "<br/>";
                                }//end of portland.
                                
                                //if austin is selected.
                                elseif($varCity == 'austin')
                                {
                                    echo "<br/>";
                                    echo "<p>Austin is the capital of the state of Texas and the seat of Travis County. Located in Central Texas on the eastern edge of the American Southwest, Austin is the thirteenth most populous city in the United States of America and the fourth most populous city in the state of Texas. It was the third-fastest-growing large city in the nation from 2000 to 2006. Austin has a population of 820,611 (2011 U.S. Census). The city is the cultural and economic center of the Austin–Round Rock–San Marcos metropolitan area, which had an estimated population 1,783,519 (2011 U.S. Census), making it the 34th-largest metropolitan statistical area in the United States and the fourth-largest in Texas.</p>";
                                    echo "<br/>";
                                }//end of austin.
                                
                                //if houston is selected.
                                elseif($varCity == 'houston')
                                {
                                    echo "<br/>";
                                    echo "<p>Houston is the fourth-largest city in the United States of America, and the largest city in the state of Texas. According to the 2010 U.S. Census, the city had a population of 2.1 million people within an area of 656.3 square miles (1,700 km2). Houston is the seat of Harris County and the economic center of Houston–Sugar Land–Baytown, the fifth-largest metropolitan area in the U.S. with over 6 million people.</p>";
                                    echo "<br/>";
                                }//end of houston.
                                
                                //if dallas is selected.
                                elseif($varCity == 'dallas')
                                {
                                    echo "<br/>";
                                    echo "<p>Dallas is the ninth most populous city in the United States of America and the third most populous city in the state of Texas. The Dallas-Fort Worth metroplex is the largest metropolitan area in The South and fourth-largest metropolitan area in the United States. Divided between Collin, Dallas, Denton, Kaufman, and Rockwall counties, the city had a population of 1,197,816 in 2010, according to the United States Census Bureau.</p>";
                                    echo "<br/>";
                                }//end of dallas.
                            }//end of cityDescription() function
                        ?>
                    
                        <?php
                            // Print if form 2 is set.
                            if(isset($_POST['formSubmit2'])) 
                            {   
                                echo "<p><strong>Chosen City: </strong> " . $varCity . "</p>" . "\n";
                                cityDescription();
                            } // end of error checking and description if statements.
                        ?>
                </td></tr>
            </table>
        </div>
        
    <hr/>
</body>
    
</html>



This post has been edited by Skunny: 26 September 2012 - 09:02 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Trouble with form submit creating another form that needs submitted

#2 Skunny  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 12-March 12

Re: Trouble with form submit creating another form that needs submitted

Posted 26 September 2012 - 09:46 AM

I adjusted the code a bit. it no longer gets an infinite string but it gets an error on line 58, 59 where $varCity and $varState are located.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
        <title>State Visit Form</title>
    
        <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
</head>
    
    <body>
        
        <div style="text-align:center;" id="header">
            <h1>State Visit Form</h1>
        </div>
        
        <hr/>
        
        <div id="content">
            
        <table style="border:1px; width:100%; height:100%">
            <tr align="center">
                <td align="center"> <h2> State Visit Form </h2></td>
                <td align="center"> <h2> You Entered: </h2></td>
            </tr>
                    
            <tr align="center">
                <td style="width:50%; height:100%; overflow:auto; padding:4px; border:1px solid black;">
                    
                <form id='stateForm' method='post' action=''>
                    <p>
                        Name:
                        <input type='text' name='formName' value="<?php echo $_POST['formName']?>"/>
                    </p>
                    <p>
                        Where would you like to visit?:
                        <select name="formState">
                            <option value="">Select One:</option>
                            <option value="California">California</option>
                            <option value="Florida">Florida</option>
                            <option value="Hawaii">Hawaii</option>
                            <option value="Maine">Maine</option>
                            <option value="Texas">Texas</option>
                        </select>
                    </p>
                    <p>
                        <input type='submit' name='formSubmit' value='Submit' /> <input type="reset" value="Start Over"/>
                    </p>
                </form>
                    
                </td>
        
                <td align="center">
                                  
                        <?php
                            // Program to display info based on state selection.
                            $varName = $_POST['formName'];
                            $varState = $_POST['formState'];
                            $varCity = $_POST['formCity'];
                                
                            function stateDescription()
                            {
                                $errorMessage = "";
                                global $varName;
                                global $varState;
                                global $varCity;
                                
                                //Check if name is entered.
                                if($varName == '')
                                {
                                    $errorMessage .= "<p>Error!: You forgot to enter a Name!</p>";
                                    echo $errorMessage;
                                } // End of Check Name. 
                                                               
                                //Check if state is selected.
                                if($varState == '') 
                                {
                                    $errorMessage .= "<p>Error!: You forgot to select a state!</p>";
                                    echo $errorMessage;
                                } // End of Check State.
                                
                                //if california is selected.
                                elseif($varState == 'California')
                                {
                                    echo "<p>California's diverse geography ranges from the Pacific Coast in the west, to the Sierra Nevada mountains in the east – from the Redwood–Douglas-fir forests of the northwest, to the Mojave Desert areas in the southeast. The center of the state is dominated by Central Valley, a major agricultural area. California contains both the highest and lowest points in the contiguous United States (Mount Whitney and Death Valley), and has the 3rd longest coastline of all states (after Alaska and Florida). Earthquakes are a common occurrence due to the state's location along the Pacific Ring of Fire: about 37,000 are recorded annually.";
                                    echo "<br/><br/>";
                                    echo "Notible Cities:"; 
                                    echo "<form id='cityForm' method='post' action=''>
                                            <p>
                                                Choose One:
                                                <select name='formCity'>
                                                    <option value=''>Select One:</option>
                                                    <option value='sanfrancisco'>San Francisco</option>
                                                    <option value='sacramento'>Sacramento</option>
                                                    <option value='lasangeles'>Las Angeles</option>   
                                                </select>
                                            </p>
                                            <p>
                                                <input type='submit' name='formSubmit2' value='Submit' /> <input type='reset' value='Start Over'/>
                                            </p>
                                         </form>";
                                        
                                         
                                         //Check if a city is entered.
                                        if($varCity == '') 
                                        {
                                            $errorMessage .= "<p>Error!: You forgot to select a city!</p>";
                                            echo $errorMessage;
                                        } // End of Check State.
                                        
                                        //if san fran is selected.
                                        if($varCity == 'San Francisco')
                                        {
                                            echo "<br/>";
                                            echo "<p>Today, San Francisco is one of the top tourist destinations in the world, ranking 35th out of the 100 most visited cities worldwide, and is renowned for its cool summers, fog, steep rolling hills, eclectic mix of architecture, and landmarks including the Golden Gate Bridge, cable cars, Alcatraz Island and its former prison, and its Chinatown.</p>";
                                            echo "<br/>";
                                        } // end of san fran.

                                        // if sacramento is selected.
                                        elseif($varCity == 'sacramento')
                                        {
                                            echo "<br/>";
                                            echo "<p>Sacramento is the capital city of the U.S. state of California and the county seat of Sacramento County. It is located at the confluence of the Sacramento River and the American River in the northern portion of California's expansive Central Valley.</p>";
                                            echo "<br/>";
                                        } // end of sacramento.

                                        // if las angeles is selected.
                                        elseif($varCity == 'lasangeles')
                                        {
                                            echo "<br/>";
                                            echo "<p>Nicknamed the City of Angels, Los Angeles is a leading world center of business, international trade, entertainment, culture, media, fashion, science, sports, technology, and education, and has been ranked the third richest city and fifth most powerful and influential city in the world. The city is home to renowned institutions covering a broad range of professional and cultural fields and is one of the most substantial economic engines within the United States.</p>";
                                            echo "<br/>";
                                        }//end of las angeles.
                                } // end if california.
                                
                                
                                //if florida is selected.
                                elseif($varState == 'Florida')
                                {
                                    echo "Much of Florida is situated on a peninsula between the Gulf of Mexico, the Atlantic Ocean, and the Straits of Florida. Its geography is marked by a coastline, by the omnipresence of water and the threat of hurricanes. Florida has the longest coastline in the contiguous United States, encompassing approximately 1,350 miles (2,170 km), and is the only state to border both the Gulf of Mexico and the Atlantic Ocean. Much of the state is at or near sea level and its terrain is characterized by sedimentary soils. The climate varies from subtropical in the north to tropical in the south. Its symbolic animals like the American alligator, Florida panther and the manatee, can be found in the Everglades, one of the most famous national parks in the world.";
                                    echo "<br/><br/>";
                                    echo "Notible Cities:"; 
                                    echo "<form id='cityForm' method='post' action=''>
                                            <p>
                                                Choose One:
                                                <select name='formCity'>
                                                    <option value=''>Select One:</option>
                                                    <option value='orlando'>Orlando</option>
                                                    <option value='miami'>Miami</option>
                                                    <option value='keywest'>Key West</option>   
                                                </select>
                                            </p>
                                            <p>
                                                <input type='submit' name='formSubmit2' value='Submit' /> <input type='reset' value='Start Over'/>
                                            </p>
                                         </form>";
                                        
                                        //Check if a city is entered.
                                        if($varCity == '') 
                                        {
                                            $errorMessage .= "<p>Error!: You forgot to select a city!</p>";
                                            echo $errorMessage;
                                        } // End of Check State.
                                        
                                        //if orlando is selected.
                                        if($varCity == 'orlando')
                                        {
                                            echo "<br/>";
                                            echo "<p>Orlando is nicknamed 'The City Beautiful' and its symbol is the fountain at Lake Eola. The current mayor is Buddy Dyer. The city is also sometimes nicknamed, 'The Theme Park Capital of the World', as it is best known for the Walt Disney World Resort (located approximately 21 miles (34 km) southwest of Downtown Orlando in Lake Buena Vista), founded by the Walt Disney Company in 1971, the Universal Orlando Resort (which consists of two parks, Universal Studios Florida and Islands of Adventure, as well as other attractions, including City Walk), SeaWorld, Gatorland, and Wet 'n Wild Water Park.</p>";
                                            echo "<br/>";
                                        }//end of orlando.

                                        //if miami is selected.
                                        elseif($varCity == 'miami')
                                        {
                                            echo "<br/>";
                                            echo "<p>Miami is a major center and a leader in finance, commerce, culture, media, entertainment, the arts, and international trade. In 2010, Miami was classified as a Alpha- World City in the World Cities Study Group’s inventory. In 2010, Miami ranked seventh in the United States in terms of finance, commerce, culture, entertainment, fashion, education, and other sectors. It ranked thirty-third among global cities.</p>";
                                            echo "<br/>";
                                        }//end of miami.

                                        //if key west is selected.
                                        elseif($varCity == 'keywest')
                                        {
                                            echo "<br/>";
                                            echo "<p>Key West is a city in Monroe County, Florida, United States. The city encompasses the island of Key West, the part of Stock Island north of U.S. 1 (the Overseas Highway) (east), Sigsbee Park (north, originally known as Dredgers Key), Fleming Key (north), and Sunset Key (west, originally known as Tank Island). Both Fleming Key and Sigsbee Park are part of Naval Air Station Key West and are inaccessible by civilians. Key West is the county seat of Monroe County. Key West is the southernmost city in the Continental United States.</p>";
                                            echo "<br/>";
                                        }//end of key west.
                                } // end if florida.
                                
                                //if hawaii is selected.
                                elseif($varState == 'Hawaii')
                                {
                                    echo "Hawaii’s diverse natural scenery, warm tropical climate, abundance of public beaches and oceanic surrounding, and active volcanoes make it a popular destination for tourists, surfers, biologists, and volcanologists alike. Due to its mid-Pacific location, Hawaii has many North American and Asian influences along with its own vibrant native culture. Hawaii has over a million permanent residents along with many visitors and U.S. military personnel. Its capital is Honolulu on the island of Oʻahu.";
                                    echo "<br/><br/>";
                                    echo "Notible Cities:"; 
                                    echo "<form id='cityForm' method='post' action=''>
                                            <p>
                                                Choose One:
                                                <select name='formCity'>
                                                    <option value=''>Select One:</option>
                                                    <option value='honolulu'>Honolulu</option>
                                                    <option value='kihei'>Kihei</option>
                                                    <option value='hilo'>Hilo</option>   
                                                </select>
                                            </p>
                                            <p>
                                                <input type='submit' name='formSubmit2' value='Submit' /> <input type='reset' value='Start Over'/>
                                            </p>
                                         </form>";
                                    
                                        //Check if a city is entered.
                                        if($varCity == '') 
                                        {
                                            $errorMessage .= "<p>Error!: You forgot to select a city!</p>";
                                            echo $errorMessage;
                                        } // End of Check State.
                                        
                                        //if honolulu is selected.
                                        if($varCity == 'honolulu')
                                        {
                                            echo "<br/>";
                                            echo "<p>In the Hawaiian language, Honolulu means 'sheltered bay' or 'place of shelter'. The old name is said to be Kou, a district roughly encompassing the area from Nuuanu Avenue to Alakea Street and from Hotel Street to Queen Street which is the heart of the present downtown district. The city has been the capital of the Hawaiian islands since 1845 and gained historical recognition following the Japanese attack on Pearl Harbor near the city on December 7, 1941.</p>";
                                            echo "<br/>";
                                        }// end honolulu.

                                        // if kihei is selected.
                                        elseif($varCity == 'kihei')
                                        {
                                            echo "<br/>";
                                            echo "<p>According to the United States Census Bureau, the CDP has a total area of 11.7 square miles (30.2 km2), of which 9.3 square miles (24.0 km2) is land and 2.4 square miles (6.2 km2), or 20.44%, is water. It is considered to be the South Side of Maui, located on the leeward side of Haleakala. The climate is arid, receiving no more than 10 inches (250 mm) of rain per year.</p>";
                                            echo "<br/>";
                                        }// end of kihei.

                                        //if hilo is selected.
                                        elseif($varCity == 'hilo')
                                        {
                                            echo "<br/>";
                                            echo "<p>Hilo is the county seat of the County of Hawaii and is located in the District of South Hilo. The town overlooks Hilo Bay, situated upon two shield volcanoes; Mauna Loa, an active volcano, and Mauna Kea, a dormant volcano upon which are sited some of the world's most important ground-based astronomical observatories.</p>";
                                            echo "<br/>";
                                        }//end of hilo.
                                } // end if hawaii.
                                
                                
                                //if maine is selected.
                                elseif($varState == 'Maine')
                                {
                                    echo "For thousands of years, indigenous peoples were the only inhabitants of the territory that is now Maine. At the time of European encounter, several Algonquian-speaking peoples inhabited the area. The first European settlement in Maine was by the French in 1604 on Saint Croix Island, by Pierre Dugua, Sieur de Mons. The first English settlement in Maine, the short-lived Popham Colony, was established by the Plymouth Company in 1607. A number of English settlements were established along the coast of Maine in the 1620s, although the rugged climate, deprivations, and conflict with the local peoples caused many to fail over the years.";
                                    echo "<br/><br/>";
                                    echo "Notible Cities:"; 
                                    echo "<form id='cityForm' method='post' action=''>
                                            <p>
                                                Choose One:
                                                <select name='formCity'>
                                                    <option value=''>Select One:</option>
                                                    <option value='bangor'>Bangor</option>
                                                    <option value='rockland'>Rockland</option>
                                                    <option value='portland'>Portland</option>   
                                                </select>
                                            </p>
                                            <p>
                                                <input type='submit' name='formSubmit2' value='Submit' /> <input type='reset' value='Start Over'/>
                                            </p>
                                         </form>";
                                         
                                        //Check if a city is entered.
                                        if($varCity == '') 
                                        {
                                            $errorMessage .= "<p>Error!: You forgot to select a city!</p>";
                                            echo $errorMessage;
                                        } // End of Check State.
                                       
                                       //if bangor is selected.
                                       if($varCity == 'bangor')
                                       {
                                           echo "<br/>";
                                           echo "<p>Bangor is a city in and the county seat of Penobscot County, Maine, United States, and the major commercial and cultural center for eastern and northern Maine. It is the principal city of the Bangor, Maine Metropolitan Statistical Area, which encompasses all of Penobscot County.</p>";
                                           echo "<br/>";
                                       }//end of bangor.

                                       //if rockland is selected.
                                       elseif($varCity == 'rockland')
                                       {
                                           echo "<br/>";
                                           echo "<p>Rockland is a city in Knox County, Maine, in the United States. As of the 2010 census, the city population was 7,297. It is the county seat of Knox County. The city is a popular tourist destination. It is a departure point for the Maine State Ferry Service to the islands of Penobscot Bay: Vinalhaven, North Haven and Matinicus.</p>";
                                           echo "<br/>";
                                       }//end of rockland.

                                       //if portland is selected.
                                       elseif($varCity == 'portland')
                                       {
                                           echo "<br/>";
                                           echo "<p>Tourists visit Portland's historic Old Port district along Portland Harbor, at the mouth of the Fore River and part of Casco Bay, and the Arts District, which runs along Congress Street in the center of the city. Portland Head Light is located in nearby Cape Elizabeth and marks the entrance to Portland Harbor.</p>";
                                           echo "<br/>";
                                       }//end of portland.
                                } // end if maine.
                                
                                
                                //if texas is selected.
                                elseif($varState == 'Texas')
                                {
                                    echo "Due to its size and geologic features such as the Balcones Fault, Texas contains diverse landscapes that resemble both the American South and Southwest. Although Texas is popularly associated with the Southwestern deserts, less than 10% of the land area is desert. Most of the population centers are located in areas of former prairies, grasslands, forests, and the coastline. Traveling from east to west, one can observe terrain that ranges from coastal swamps and piney woods, to rolling plains and rugged hills, and finally the desert and mountains of the Big Bend.";
                                    echo "<br/><br/>";
                                    echo "Notible Cities:"; 
                                    echo "<form id='cityForm' method='post' action=''>
                                            <p>
                                                Choose One:
                                                <select name='formCity'>
                                                    <option value=''>Select One:</option>
                                                    <option value='austin'>Austin</option>
                                                    <option value='houston'>Houston</option>
                                                    <option value='dallas'>Dallas</option>   
                                                </select>
                                            </p>
                                            <p>
                                                <input type='submit' name='formSubmit2' value='Submit' /> <input type='reset' value='Start Over'/>
                                            </p>
                                         </form>";
                                         
                                         //Check if a city is entered.
                                        if($varCity == '') 
                                        {
                                            $errorMessage .= "<p>Error!: You forgot to select a city!</p>";
                                            echo $errorMessage;
                                        } // End of Check State.
                                
                                        //if austin is selected.
                                        elseif($varCity == 'austin')
                                        {
                                            echo "<br/>";
                                            echo "<p>Austin is the capital of the state of Texas and the seat of Travis County. Located in Central Texas on the eastern edge of the American Southwest, Austin is the thirteenth most populous city in the United States of America and the fourth most populous city in the state of Texas. It was the third-fastest-growing large city in the nation from 2000 to 2006. Austin has a population of 820,611 (2011 U.S. Census). The city is the cultural and economic center of the Austin–Round Rock–San Marcos metropolitan area, which had an estimated population 1,783,519 (2011 U.S. Census), making it the 34th-largest metropolitan statistical area in the United States and the fourth-largest in Texas.</p>";
                                            echo "<br/>";
                                        }//end of austin.

                                        //if houston is selected.
                                        elseif($varCity == 'houston')
                                        {
                                            echo "<br/>";
                                            echo "<p>Houston is the fourth-largest city in the United States of America, and the largest city in the state of Texas. According to the 2010 U.S. Census, the city had a population of 2.1 million people within an area of 656.3 square miles (1,700 km2). Houston is the seat of Harris County and the economic center of Houston–Sugar Land–Baytown, the fifth-largest metropolitan area in the U.S. with over 6 million people.</p>";
                                            echo "<br/>";
                                        }//end of houston.

                                        //if dallas is selected.
                                        elseif($varCity == 'dallas')
                                        {
                                            echo "<br/>";
                                            echo "<p>Dallas is the ninth most populous city in the United States of America and the third most populous city in the state of Texas. The Dallas-Fort Worth metroplex is the largest metropolitan area in The South and fourth-largest metropolitan area in the United States. Divided between Collin, Dallas, Denton, Kaufman, and Rockwall counties, the city had a population of 1,197,816 in 2010, according to the United States Census Bureau.</p>";
                                            echo "<br/>";
                                        }//end of dallas.
                                } // end if texas.     
                            }
                        ?>
                        <?php
                            // Print if form is set.
                            if(isset($_POST['formSubmit'])) 
                            {    
                                echo "<p><strong>Name: </strong> " . $varName . "</p>" . "\n";
                                echo "<p><strong>Chosen State: </strong> " . $varState . "</p>" . "\n";
                                stateDescription();
                                
                                if(isset($_POST['formSubmit2'])) 
                                {   
                                    echo "<p><strong>Chosen City: </strong> " . $varCity . "</p>" . "\n";
                                    cityDescription();
                                } // end of error checking and description if statements.
                            } // end of error checking and description if statements.
                        ?>
                </td></tr>
            </table>
        </div>
        
    <hr/>
</body>
    
</html>


Was This Post Helpful? 0
  • +
  • -

#3 laytonsdad  Icon User is online

  • Cheese and Sprinkles
  • member icon

Reputation: 451
  • View blog
  • Posts: 1,947
  • Joined: 30-April 10

Re: Trouble with form submit creating another form that needs submitted

Posted 26 September 2012 - 09:48 AM

Why are you not using a database to store this info? It would be much cleaner.
Was This Post Helpful? 0
  • +
  • -

#4 Skunny  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 12-March 12

Re: Trouble with form submit creating another form that needs submitted

Posted 26 September 2012 - 10:17 AM

the assignment doesnt call for a db :/ I keep getting an error when trying to submit the city
"error: you forgot to enter a name" I think there is something wrong with my if statements and such I just cant see it.
Was This Post Helpful? 0
  • +
  • -

#5 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3577
  • View blog
  • Posts: 10,442
  • Joined: 08-June 10

Re: Trouble with form submit creating another form that needs submitted

Posted 26 September 2012 - 10:15 PM

have you checked that the constructed HTML is correct in every run?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1