Are headers supported in free hosting

Hi I had some scripts with

header()

all my domains with this get suspended
its the only thing i can think of that’s possibly wrong with my scripts
pls help

2 Likes

Of course, header calls are no issues. If we didn’t want you to use that function, we could have just disabled it.

I have this script it’s supposed to handle logins but it suspends the website first it was named file.php then I named it login.php cause file.php is like the default name I choose.

<?php
session_start();
?>
<?php

//for debug: echo session_id();

if (empty($_POST) == true and strpos(file_get_contents("sessions.txt"), session_id() == false))
{
  header("Location: index.php");
}
elseif (strpos(file_get_contents("sessions.txt"), session_id()) !== false)
{
  //pass
}
elseif (empty($_POST) !== true and hash("sha256", $_POST["auth"]) == "d09de118fa99b279ae60ddba9f9ce4afcade38c0578188df67ac79f05b514856")
{
  $filetowrite = fopen("sessions.txt", "a");
  fwrite($filetowrite, session_id() . "\n");
  fclose($filetowrite);
}
else
{
  header("Location: index.php");
}
?>
<!DOCTYPE html>
<html>
  <head>
    <title></title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
      body {
        font-family: sans-serif;
        word-wrap: break-word;
      }
    </style>
  </head>
  <body>
    <p>Welcome</p>
    <hr>
    <p>Sory for the website not looking very new and modern its just for compatibility.</p>
    <br>
    <center>
      <p>What am i up to?</p>
    </center>
    <div>
      <article>
        <p>Test Post</p>
        <p><a href="files.php">Go to test post.</a></p>
      </article>
    </div>
  </body>
</html>
```

script2 (index.php)

```
<?php
  session_start();
?>
<!DOCTYPE html>
<html>
  <head>
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
  body {
    font-family: sans-serif;
    word-wrap: break-word;
  }
</style>
  </head>
  <body>
  <center>
<p>Webpage is password protected</p>
<form method="POST" action="files.php">
  <input type="password" name="auth" placeholder="password">
  <input type="submit" value="submit">
</form>
  </center>
<?php
  date_default_timezone_set('America/Los_Angeles');

  // for debug: echo session_id();

  if (date('l') !== file_get_contents('date'))
  {
    $file = fopen("key.key", "w");
    fwrite($file, hash("sha256", random_bytes(32)));
    fclose($file);
    $file = fopen("date", "w");
    fwrite($file, date('l'));
    fclose($file);

    if (filesize("sessions.txt") >= 8000000)
    {
      $file = fopen("sessions.txt", "w");
      fwrite($file, "");
      fclose($file);
    }
  }
?> 
  </body>
</html>

If you want to discuss other possible reasons why your account may be suspended, could you please contain that to a single topic so the entire discussion in a single thread, not fragmented over multiple?

Well I did try removing the headers on another account and it worked fine so I’m sure its them. also on other thread I got not much helpful responses

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.