php - Cannot modify header information error? -


this question has answer here:

ik prob dupe, cant find solutions code ever, no matter code add/change, wont budge... (note im not using normal php, using friends version, yes, fine , dandy)

<?php include($_server['document_root'].'/phpalphadb/core.php'); ?>  <html> <head> <link rel="icon" type="image/png" href="../logo.png">     <title> xenoz web - users </title>     <link rel="stylesheet" type="text/css" href="../css/style.php" />     <meta http-equiv="content-type" content="text/html; charset=utf-8"> </head> <?php     if ($role==0) {     header('location: http://xenozweb.tk/index.php'); } else {         echo '<script>alert("hello, '.$username.'. welcome userlist...");</script>';     }     ?>  <body>     <div class="navigation">         <a href="index.php"><div class="navitem"> home </div></a>               <a href="/register/"><div class="navitem"> register </div></a>         <a href="/login/"><div class="navitem"> login </div></a>         <a href="/users/"><div class="navitem"> users </div></a>         <a href="/jukebox/"><div class="navitem"> jukebox </div></a>         </div>     </div>     <div class="pagecontent">        <div class="userblock">         <?php           $results = db_read('xenozweb-users', '',  'username');           foreach ($results $result) {           $u_name = db_column($result, 0);           echo '<div class="users">',$u_name,'</div>';           }             ?>         </div>     </div> </body> </html> 

you're returning partial response before set header. headers must sent before response sent browser.

try moving header('location: ') function call top <?php enclosure so:

<?php     include($_server['document_root'].'/phpalphadb/core.php');      if ($role==0) {         header('location: http://xenozweb.tk/index.php');     } ?>  <html> <head> <link rel="icon" type="image/png" href="../logo.png"> <title> xenoz web - users </title> <link rel="stylesheet" type="text/css" href="../css/style.php" /> <meta http-equiv="content-type" content="text/html; charset=utf-8">  <?php      if ($role != 0) {         echo '<script>alert("hello, '.$username.'. welcome userlist...");</script>';     } ?>  </head> <body> 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -