How do you write for SSL in PHP?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AaronL
    New Member
    • Jan 2007
    • 99

    How do you write for SSL in PHP?

    Hi everyone,

    I've been working on e-commerce software for a couple of years and I was wondering, if I were to make a cart, I know I need to host it on a secure server. Are there resources for getting a dummy like me started on something like that? Also, I will be storing customer name, phone number, and address etc... in the database as well, does that information get encrypted in the database usually with ecommerce software? If so, how do I go about encrypting and decrypting the data when needed?

    Thanks!
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    SSL is setup with the webserver software (Apache or IIS), usually a site is configured for both. That means you can access both index.php using http and httpS .

    Once that is done and implemented (a certificate from a reputable company is required, such as Verisign) the PHP side is very easy.

    On all the pages you want encrypted, you need to redirect if it's not HTTPS. To do this you test to see if the site is being access through regular http, if it is, you forward (redirect) to https.

    One variation of doing that is:
    Code:
    if(empty($_SERVER['HTTPS'])) {
       header("HTTP/1.1 301 Moved Permanently"); 
       header("Location: "https://" . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]);
       exit();
    }
    Good luck,

    Dan

    Comment

    • smoran
      New Member
      • Nov 2011
      • 3

      #3
      SSL encrypts data transfered from your page..
      Your actual PHP scripts remains the same..
      there is no need for a Special function to use SSL.

      Comment

      • Artnessde
        New Member
        • Nov 2011
        • 13

        #4
        if you need encryption inside your e.commerce database you could use the mysql aes_encrypt/decrypt functions which is 128bit encryption.

        Comment

        Working...