05.05.2013 Views

Programming PHP

Programming PHP

Programming PHP

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

page, and actually adding the information to the database. The value passed into the<br />

script by the submit button indicates how the script should behave. We use autocommit<br />

to optimize the code somewhat: if we’re displaying the confirmation page,<br />

we turn off autocommit, add the record to the database, and display it. When the<br />

script ends, the addition is rolled back. If we’re actually adding the information, we<br />

leave autocommit on but otherwise do exactly the same database steps as for confirmation,<br />

so the addition isn’t rolled back at the end of the script.<br />

Example 15-5. Add new phone number, with confirmation<br />

<br />

<br />

ODBC Transaction Management<br />

<br />

<br />

Phone List<br />

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

Saved successfully!

Ooh no, something went wrong!