Integrating Flex & PHP - An Introductory Tutorial
Adding New Employees
The third PHP script handles the adding of new employees. You could submit new records to this script using a standard HTML form, but I’m using pure Flex instead (see the next figure).
Regardless of where the data comes from, the PHP page that handles the new employee data needs to validate it, insert the record into the database, and report upon the results. The add_employee.php script in the downloadable source code does all this. Looking at that code, you’ll see that…
• I’m performing just basic validation of the three values; this could be improved upon using regular expressions.
• For extra security, I use prepared statements, which will prevent SQL injection attacks.
• The script creates no HTML, just plain text.
This last point is the most important, as the results of this script (i.e., whatever would otherwise be seen in the Web browser) will be displayed in an alert box by the Flex application (see the next two figures).
| Attachment | Size |
|---|---|
| leu_flex_php_1.1.png | 69.58 KB |
| leu_flex_php_1.2.png | 10.2 KB |
| leu_flex_php_1.3.png | 14.37 KB |
| leu_flex_php_1.4.png | 13.05 KB |
| leu_flex_php_1.5.png | 9.63 KB |
| leu_flex_php_1.6.png | 7.71 KB |
| larry_ullman_flex_php1_code.zip | 382.27 KB |
- Login or register to post comments
- 17009 reads
- Printer-friendly version
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)











Comments
dazweeja replied on Thu, 2009/05/28 - 6:34pm
LarryUllman replied on Sun, 2009/05/31 - 9:10pm
in response to: dazweeja
dengiz replied on Sun, 2009/06/07 - 7:34pm
thanks a lot for this great tutorial. That is exactly what I was searching for!
Just one question: departments_xml.php didn't function properly. I couldn't find why.
LarryUllman replied on Mon, 2009/06/15 - 1:32pm
kalchuka replied on Sat, 2009/06/20 - 6:42am
LarryUllman replied on Mon, 2009/06/22 - 10:12am
danieldourado_2 replied on Tue, 2009/07/14 - 5:02pm