13.09.2016 Views

PHP and MySQL Web Development 4th Ed-tqw-_darksiderg

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Adding Ajax Elements to Earlier Projects<br />

875<br />

The following line of code has been added after the closing form tag in the <strong>PHP</strong> function<br />

display_add_bm_form(); this is the div in which the result from the server will be<br />

displayed to the user.<br />

<br />

Next, you will have to make modifications to the existing add_bms.php code.<br />

Additional Modifications to Existing Code<br />

If you were to attempt to add a bookmark without modifying anything in the<br />

add_bms.php script, the actual process of checking user permissions <strong>and</strong> adding a bookmark<br />

would work just fine. However, the result would be the monstrosity seen in Figure<br />

34.4, which includes the duplication of the title, logo, <strong>and</strong> footer links, as well as other<br />

issues with the application display.<br />

Figure 34.4<br />

Adding a bookmark before editing the add_bms.php script.<br />

In the non-Ajax version of the <strong>PHP</strong>bookmark application, remember that the form is<br />

one page, the submission result is another, <strong>and</strong> all page elements are reloaded at all times.<br />

However, in this Ajax-enabled environment, you want to add a new bookmark, get the<br />

result from the server, <strong>and</strong> continue on to add more bookmarks (or not) without reloading<br />

any page elements.This new functionality necessitates some changes to the<br />

add_bms.php code.The original code is shown in Listing 34.8.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!