Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

My website isn't displaying the way it should.

//include config
require_once('includes/config.php');

//check if already logged in move to home page
if( $user->is_logged_in() ){ header('Location: memberpage.php'); } 

//process login form if submitted
if(isset($_POST['submit'])){

    $username = $_POST['username'];
    $password = $_POST['password'];

    if($user->login($username,$password)){ 

        header('Location: memberpage.php');
        exit;

    } else {
        $error[] = 'Wrong username or password or your account has not been activated.';
    }

}//end if submit

//define page title
$title = 'Login';

//include header template
require('layout/header.php'); 
?>

<html>
<head>
<meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>You have found the egg</title>

    <!-- Bootstrap Core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="css/sb-admin.css" rel="stylesheet">
    <link href="css/easter.css" rel="stylesheet">

    <!-- Morris Charts CSS -->
    <link href="css/plugins/morris.css" rel="stylesheet">

    <!-- Custom Fonts -->
    <link href="font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>

<!--<form  method="post" action=""> -->
    <form role="form" method="post" action="" autocomplete="off">
    <div id="fullBg" />


<div id="fullscreen_bg" class="fullscreen_bg"/>

<div class="container">

    <form class="form-signin">

        <h1 class="form-signin-heading text-muted">Grade Manager.</h1>
        <div class="form-group">
                    <input type="text" name="username" id="username" class="form-control" placeholder="User Name" required="" autofocus="" value="<?php if(isset($error)){ echo $_POST['username']; } ?>" tabindex="1">
                   <input type="password" name="password" id="password" class="form-control" placeholder="Password"  required=""tabindex="3">


                <!--<div class="row">
                    <div class="col-xs-9 col-sm-9 col-md-9">
                         <a href='reset.php'>Forgot your Password?</a>
                    </div>
                </div> -->


                    <div class="col-xs-6 col-md-6"><input type="submit" name="submit" value="Login" class="btn btn-lg btn-primary btn-block" tabindex="5"></div>
                </div>
            </form>
        </div>
    </div>



</div>


</div>



        <!--<div class="col-xs-12 col-sm-8 col-md-6 col-sm-offset-2 col-md-offset-3"> -->
            <form role="form" method="post" action="" autocomplete="off">

                <!--<p> We believe that every student should have an equal chance. No matter what the situation is. So we have created a beautifully engineered grade predictor program that predicts your UCAS grade fairly, precisely using advanced algorithms. </p>
                <p><a href='contact.php'>Contact us to get an invite !</a></p>
                <hr> -->

                <?php
                //check for any errors
                if(isset($error)){
                    foreach($error as $error){
                        echo '<p class="bg-danger">'.$error.'</p>';
                    }
                }

                if(isset($_GET['action'])){

                    //check the action
                    switch ($_GET['action']) {
                        case 'active':
                            echo "<h2 class='bg-success'>Your account is now active you may now log in.</h2>";
                            break;
                        case 'reset':
                            echo "<h2 class='bg-success'>Please check your inbox for a reset link.</h2>";
                            break;
                        case 'resetAccount':
                            echo "<h2 class='bg-success'>Password changed, you may now login.</h2>";
                            break;
                    }

                }


                ?>


<!--<div id="fullBg" />

<div id="fullscreen_bg" class="fullscreen_bg"/>

<div class="container">

    <form class="form-signin">

        <h1 class="form-signin-heading text-muted">GradeManager.</h1>
        <input type="text" name="usernname" id ="username" class="form-control" placeholder="User Name" required="" autofocus="" value="<?php if(isset($error)){ echo $_POST['username']; } ?>" tabindex="1">

        <input type="password" name="password" id="password" class="form-control" placeholder="Password" required="" tabindex="2">

        <button class="btn btn-lg btn-primary btn-block" type="submit" value="Login">
            Sign In
        </button>
    </form>

</div> -->

``` <form role="form" method="post" action="" autocomplete="off">

When i remove that line of code my website displays correctly, however the website login doesn't work when i remove this code. Can anyone help ?

<form role="form" method="post" action="" autocomplete="off">
fyhrr
fyhrr
7,035 Points

I haven't looked too in-depth, but do you have a beginning ?php in your actual page? Looks like it's missing from this one, but I wasn't sure if you just didn't paste that line in.