PHP:Force a secure HTTP connection
Monday, June 30th, 2008if (!($HTTPS == “on”)) {
header (”Location: https://$SERVER_NAME$php_SELF”);
exit;
}
if (!($HTTPS == “on”)) {
header (”Location: https://$SERVER_NAME$php_SELF”);
exit;
}
<?php
/**
* valid_url - validates supplied url with a regular expression ( regex ).
*
* URL can be FTP, HTTP secure
* @param $url String
* @return true if the address is valid
* @author RAJI
*
*/
function valid_url( $url )
{
if ( !preg_match( ‘!^((ht|f)tps?://)?[a-zA-Z]{1}([w-]+.)+([w]{2,5})/?$!i’, $url ) )
{
return false;
} else
{
return true;
}
}
if ( valid_url( “http://blog.tryangled.com” ) )
{
echo “URL OK”;
} else
{
echo “Invalid URL.”;
}
?>
if (!($HTTPS == “on”)) {
header (”Location: https://$SERVER_NAME$php_SELF”);
exit;
Firefox looks for a secure connection before installing or updating add-ons, 3rd party software, and Personas.
If you are planning to get or already have a merchant account that enables you to process credit cards you need to have a web site with a secure connection. This provides a way to encrypt sensitive data so that it cannot be intercepted and read as it travels across the Internet. If you don’t have a secure connection (indicated by https at the start of a web address) forget about collecting credit card numbers – customers are too web savvy to post sensitive financial data on an unsecured web site.
In order to get a secure connection, you need to apply for an SSL (Secure Sockets Layer) certificate. These are issued by companies such as Thawte which require you to supply verifiable information concerning your identity and location. Once you have the certificate it must be installed on your web site. For this you need to have a unique IP address – available at an extra cost from most web hosts. There may also be a fee to install the certificate.
One of the fastest growing sectors of the Internet is eCommerce. People are becoming accustomed to buying things from Internet store fronts and every year the volume and value of sales increases substantially. If you would like to open up your own eCommerce web site here are a few basics to get you started.
The first thing you need, obviously, is a product or service that you can sell. If you already have a brick and mortar store you can offer the same items for sale on a web site. The number of products that you sell is a big factor in the type of hosting package you need. If you have let’s say less than 20 items, you could set the whole thing up on a very small hosting account. Listing hundreds of products is a different story – you will probably need more disk space, more bandwidth, and more features such as databases and a secure connection for accepting payments.
Since the most important part of eCommerce is getting paid, let’s look at the various payment options available. There are two basic options – collecting payment information directly or hiring a third-party service to process credit cards.