-1

i just passed from my xampp server to bluehost hosting service. and im having problems...

So here is the story, before i bought my hosting plan they told me that any php code within a .html would be executed (just like on my xampp server). well it doesn't work... i asked them for help and they told me i had to change the file to .php and that i didn't need to change any of the code inside. so i did, and it doesn't work... im geting:

Cannot modify header information - headers already sent by (output started at /home7/.../public_html/index.php:10) in /home7/.../public_html/index.php on line 28

i have done some research for the past 7 straight hours and cant get it to work.

here is the code:

<html>
<head>
<?phpsession_start();


//check if logged in
function isLoggedIn()
{
    if(isset($_SESSION['valid']) && $_SESSION['valid'])
        return true;
    return false;
}

//if the user has not logged in
if(!isLoggedIn())
{
    header('Location: login_form.html');
}

/*-----Connect to Database-----*/
include ('connect_database_2.php');

/* get username */
$username = $_SESSION['username'];


/*-----Include Navigation------*/
include ('frame.html');
?>


<LINK href="stylesheets/blog_index_stylesheet.css" rel="stylesheet" type="text/css">

    <title>Blog Photos</title>

i tried putting <?phpsession_start(); at the very start but i get a server 500 error or something like that, i told that to the host and they told me it was a scripting error.

user1107703
  • 87
  • 4
  • 12

2 Answers2

2

At least for that first line, you will want to write it like this:

<?php session_start(); ?>

And make sure to put it at the very top of your file. (Even above the HTML.)

summea
  • 7,390
  • 4
  • 32
  • 48
1

You can only send cookies before any actual HTML data is sent, because when first character (even space or new line) is sent, headers are sent too.

Just move your <html><head> tags after the ?>.

Remc4
  • 1,044
  • 2
  • 12
  • 24