Virtual web hosting - 406 CHAPTER 13 CASE STUDY: USING PHP
Thursday, January 17th, 2008406 CHAPTER 13 CASE STUDY: USING PHP FOR AN XML APPLICATION It then retrieves the details from the form, including the values in the hidden fields: $into = $_POST[’into’]; $current = $_POST[’current’]; $parent = $_POST[’parent’]; $entry = $_POST[’entry’]; The page tests to see that users have entered details into the form: if (strlen(trim($entry)) > 0) { If so, it uses the $into variable to determine the appropriate INSERT statement and stores it in the variable $sql: switch ($into) { case ‘continent’: $sql = ‘INSERT into continent (continent) . VALUES (”‘ . htmlspecialchars($entry,ENT_QUOTES) . ‘”)’; break; case ‘country’: $sql = ‘INSERT into country (country, countryContinentID) . VALUES (”‘ . htmlspecialchars($entry,ENT_QUOTES) . ‘”,’ . $parent . ‘)’; break; case ‘area’: $sql = ‘INSERT into area (area, areaCountryID) . VALUES (”‘ . htmlspecialchars($entry,ENT_QUOTES) . ‘”,’ . $parent . ‘)’; break; case ‘city’: $sql = ‘INSERT into city (city, cityAreaID) . VALUES (”‘ . htmlspecialchars($entry,ENT_QUOTES) . ‘”,’ . $parent . ‘)’; break; default: $sql = ‘’; break; } } else { $sql ='’; } Finally, the code checks for a SQL statement, in which case the length of the $sql variable must be greater than 0. It then inserts the new record and redirects to the previous navigation position:
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.