0

Undefined index: HTTPS in /XXX/index.php on line 35 at post.

if($_SERVER['HTTPS'] == 'on'){
    $mydomain = 'https://'.$_SERVER['HTTP_HOST'];
} else {
    $mydomain = 'http://'.$_SERVER['HTTP_HOST'];
}

The code at line 35 are as follows;

if($_SERVER['HTTPS'] == 'on'){
  • check if it set before use try if(isset($_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'on') – Omi Mar 20 '17 at 18:26
  • 1
    More a duplicate of [Undefined index error using $_SERVER['HTTPS'\]](http://stackoverflow.com/questions/4911532/undefined-index-error-using-serverhttps) – Tom Udding Mar 20 '17 at 18:27
  • @Omi Fatal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead) – Drama Online Mar 20 '17 at 18:32
  • @DramaOnline please check you have closed isset bracket before && – Omi Mar 20 '17 at 18:37

1 Answers1

0

check if the variable $_SERVER isset before checking the $_SERVER value

this line

if($_SERVER['HTTPS'] == 'on'){

should be as follows

if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on'){
hassan
  • 7,812
  • 2
  • 25
  • 36