By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,401 Members | 803 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,401 IT Pros & Developers. It's quick & easy.

How do you write for SSL in PHP?

AaronL
P: 99
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!
Nov 4 '11 #1
Share this Question
Share on Google+
3 Replies


dlite922
Expert 100+
P: 1,584
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:
Expand|Select|Wrap|Line Numbers
  1.  
  2. if(empty($_SERVER['HTTPS'])) {
  3.    header("HTTP/1.1 301 Moved Permanently"); 
  4.    header("Location: "https://" . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]);
  5.    exit();
  6. }
  7.  
  8.  
Good luck,

Dan
Nov 4 '11 #2

P: 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.
Nov 17 '11 #3

P: 13
if you need encryption inside your e.commerce database you could use the mysql aes_encrypt/decrypt functions which is 128bit encryption.
Nov 26 '11 #4

Post your reply

Sign in to post your reply or Sign up for a free account.