Prev | Current Page 64 | Next

Larry Ullman

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


68 adding records via Ajax
$fn = mysql_real_escape_string($_POST[???first_name??™],
$dbc);
} else {
$error = true;
echo ???first_name
???;
}
if (!empty($_POST[???last_name??™])) {
$ln = mysql_real_escape_string($_POST[???last_name??™],
3 To make sure the data is safe to use in a query, text inputs are
run through the mysql_real_escape_string() function.
adding records via Ajax 69
validate the form data (cont.)
} else {
$error = true;
echo ???last_name
???;
}
if (!empty($_POST[???email??™])) {
$e = mysql_real_escape_string($_POST[???email??™],
$dbc);
} else {
$error = true;
echo ???email
???;
}
70 adding records via Ajax
4 Numeric values, like the department ID and the phone extension,
must be positive numbers.
5 To make them safe to use in a query, numeric values are type-cast
as integers.
6 Any failed validation routine results in the $error variable being set
to true.
7 To report the error back to the JavaScript, an XML element is created
with a name of error. The value of the XML element is the name of the
form element improperly fi lled out.


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