Below is the code.
else if ($_REQUEST['what'] == 'comment')
{
$rc = new RecipeComment("recipeComments", $_REQUEST);
$rc->dateUpdated = date("Y-m-d H:i:s");
if ($rc->Save())
{
echo "
Comment saved.
";
}
else
{
echo "
Could not save your comment.
";
}
}
5. The following screenshot shows how submitted comments and our form
may display in a mobile browser. It's actually just like any other browser!
And if we want to make it a bit more interesting, we can send back the
actual comment in the output along with the message that the comment was
saved. This will display the comment to the user, giving her or him instant
gratification! That's what we want, isn't it?
Chapter 10
[ 197 ]
What's the Deal with All that Form Code?
The biggest piece in the comments code is the form processing. It's the JavaScript
way of accessing values from form elements. The source and target bit are simply
pointers to two forms. The source form is the one we got from the GetRecipe()
request, and the target form is the one the user filled. We pick up the recipeId
from the source form (as without that, our comment will be orphaned), club it with
other values from the target form, and push the URL across.
Pages:
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264