Build Your Own AJAX Web Applications by Matthew Eernisse

Build Your Own AJAX Web Applications by Matthew Eernisse

Author:Matthew Eernisse [Eernisse, Matthew]
Language: eng
Format: epub, mobi, pdf
ISBN: 0975841947
Publisher: SitePoint Pty. Ltd.
Published: 2006-08-16T04:00:00+00:00


The PHP Code

Here’s the code for the back-end page:

blog_process.php (excerpt)

<?php $editEntryId = $_POST["editEntryId"]; sleep(3); header("Content-Type: text/plain"); print "---\n"; print "status: success\n"; if ($editEntryId == "NewEntryTemp") { print "type: new\n"; print "id: " . time() . "\n"; } else { print "type: edit\n"; print "id: " . $editEntryId . "\n"; } print "..."; ?>

This fairly short chunk of PHP basically does the same thing whether you’re saving a new entry or editing an existing one.

In both cases, it returns the ID of the entry—either the ID for an edited entry that’s passed in from the browser, or a pretend ID that’s generated by the PHP time function to mimic the value that would be returned if this code were actually saving something to a database (like a MySQL auto_increment field, or a PostgreSQL serial). The main difference is whether the type is set to new or edit.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.