Page 1 of 1
HTTPS
Posted: Tue Mar 10, 2009 5:32 pm
by SheDesigns
So apparently my client has a secure server.. I have no idea how to utilize that. We're taking social security numbers, so it's a big deal that it is secure.
How do I make a page a HTTPS instead of a regular ol' HTTP?
Re: HTTPS
Posted: Tue Mar 10, 2009 5:55 pm
by kaisellgren
Mostly things are handled by the server. Not much to do with PHP. You have to ensure that the page is loaded in HTTPS, for instance:
Code: Select all
<?php
function force_ssl()
{
if ($_SERVER['SERVER_PORT'] != "443") // HTTPS
{
$url = "https://".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] ? '?'.$_SERVER['QUERY_STRING'] : '');
header("Location: $url");
exit;
}
}
force_ssl();
echo <<<HTML
<form method="post">
<input type="text" />
</form>
HTML;
?>
That form will be forced to load in HTTPS.
Re: HTTPS
Posted: Wed Mar 11, 2009 4:44 am
by arjan.top
you have $_SERVER['HTTPS'] too
Re: HTTPS
Posted: Wed Mar 11, 2009 9:32 am
by kaisellgren
arjan.top wrote:you have $_SERVER['HTTPS'] too
Yes. Just remember that on IIS through ISAPI, the value is "off" in case the connection is not HTTPS.