Prev | Current Page 63 | Next

Larry Ullman

"Building a Web Site with Ajax: Visual QuickProject Guide"

This data will be handled by the JavaScript
in the Web browser. Start a new PHP script in your text-editing application.
1 This PHP page will not be viewed in the Web browser, so it
begins with the opening PHP tag, not with HTML. (See extra
bits on page 83.)
2 The header() function is used to send meta-information
(i.e., not actual data). Here the header() function sends a
Content-Type of text/xml. In layman??™s terms, this is a way of
saying that XML data should be expected to follow.
3 XML data begins wth the declaration.
4 All XML documents have one root element. This can be
a made-up value, like response here.
header(???Content-Type: text/xml???);
echo ???standalone=???yes??? ?>

???;
adding records via Ajax 67
validate the form data
The form data must be validated prior to using it in a query. Add this code to
the PHP page.
2 Text inputs will be validated by confi rming that they aren??™t empty.
(See extra bits on page 84.)
??¦

???;
require_once(???mysql.inc.php??™);
$error = false;
if (!empty($_POST[???first_name??™])) {
1 The $error variable will be a fl ag, indicating if an error occurred.


Pages:
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75