0

The xampp server does not work with the following code

  if(isset($_SESSION['username'])){
header("Location:Home.php");
exit();
}else{ ?> hi dear<? } ?>

but the code works on appserv In Server Xampp I have a problem with the appearance of pages not formatted like this and i have to do this code such that

if(isset($_SESSION['username'])){
header("Location:Home.php");
exit();
}else{ echo" hi dear"; } ?>

what is the solve?

qutayba
  • 33
  • 5

3 Answers3

1

I found in my projects that code is not working with short php tags <?, try to replace them with standard ones <?php. And give it a shot. Hope it'll help.

Bartosz Was
  • 116
  • 1
  • 9
0

Did u type session_start(); on the top of the document?

Could u provide the error thet PHP shows?

Take it out of the IF and see if it works

on my document i have this:

 if (isset($_SESSION['user']) && isset($_SESSION['password'])) {
    Header( 'Location: ../index.php' ) 
    exit
    }else{
       echo 'hello world';
    }
mto_norte
  • 1
  • 1
0

Try This One. It will work.

<?
   if(isset($_SESSION['username'])){
      header("Location:Home.php");
      exit();
   }else{ ?> 
      <?= hi dear" ?> 
<? } ?>