SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Mar 2008
    Location
    Sterling, CO
    Posts
    275
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Notice: Undefined index: HTTPS

    Hi,

    I have a small little problem that kinda bugs me for a while now and thought I would try to fix it once and for all.

    Code:
    <?php
    function curPageURL() {
    $pageURL = 'http';
    if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
    $pageURL .= "://";
    if ($_SERVER["SERVER_PORT"] != "80") {
    $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];} 
    else {$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; }
    return $pageURL;}
    ?>
    Any ideas how can I fix this error here?

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,406
    Mentioned
    149 Post(s)
    Tagged
    4 Thread(s)
    PHP Code:
    if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on')) 

  3. #3
    SitePoint Addict
    Join Date
    Mar 2008
    Location
    Sterling, CO
    Posts
    275
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot,

    That fixed it!

  4. #4
    SitePoint Member
    Join Date
    Jul 2013
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code PHP:
    if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on'))

    This code shows the scenario "Operation Success but the Patient was Died." Because, The error was undefined index HTTPS in the $_SERVER Variable. My goal is to navigate a http page to https page. But this code automatically leads to the else part. It only helps to fix the E_NOTICE & E_WARNING...

    Give me the best solution to redirect http to https...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •