13.09.2016 Views

PHP and MySQL Web Development 4th Ed-tqw-_darksiderg

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

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

Implementing an Administration Interface<br />

641<br />

You process the user’s card <strong>and</strong>, if all is successful, destroy her session.<br />

The card processing function as it is written simply returns true. If you were actually<br />

implementing it, you would need to perform some validation (checking that the expiry<br />

date was valid <strong>and</strong> the card number well formed) <strong>and</strong> then process the actual payment.<br />

When you set up a live site, you need to make a decision about what transaction<br />

clearing mechanism you want to use.You can<br />

n Sign up with a transaction clearing provider.There are many, many alternatives<br />

here depending on the area you live in. Some of them offer real-time clearing, <strong>and</strong><br />

others don’t.Whether you need live clearing depends on the service you are offering.<br />

If you are providing a service online, you will most likely want it; if you are<br />

shipping goods, it’s less crucial. Either way, these providers relieve you of the<br />

responsibility of storing credit card numbers.<br />

n Send a credit card number to yourself via encrypted email, for example, by<br />

using Pretty Good Privacy (PGP) or Gnu Privacy Guard (GPG), as covered in<br />

Chapter 18.When you receive <strong>and</strong> decrypt the email, you can process these transactions<br />

manually.<br />

n Store the credit card numbers in your database.We do not recommend this option<br />

unless you really, seriously know what you’re doing with system security. Read<br />

Chapter 18 for more details about why this is a bad idea.<br />

That’s it for the shopping cart <strong>and</strong> payment modules.<br />

Implementing an Administration Interface<br />

The administration interface we implemented is very simple.We just built a <strong>Web</strong> interface<br />

to the database with some front-end authentication.This interface uses much of the<br />

same code as used in Chapter 27.We included it here for completeness, but with little<br />

discussion.<br />

The administration interface requires a user to log in via the login.php file, which<br />

then takes him to the administration menu, admin.php.The login page is shown in<br />

Figure 28.11. (We omitted the login.php file here for brevity; it’s almost exactly the<br />

same as the one in Chapter 27. If you want to look at it, it’s on the CD-ROM.) The<br />

administration menu is shown in Figure 28.12.

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

Saved successfully!

Ooh no, something went wrong!