-3

Parse error: syntax error, unexpected end of file in C:\Users\p\Desktop\xampp\htdocs\myproject\login.php on line 55

So I dont know what is causing this problem I have only started to learn Php and Html. Can anyone help fix this.

Here is the code.

Line 55 is at the bottom.

if(isset($_POST['submit'])) {

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


    $connection = mysqli_connect('localhost', 'root', 'root', 'loginapp');

        if($connection) {

        echo "We are connected";

        } else {
        }

        die("Database connection failed");

 ?>       




<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
</head>
<body>
<div class="container">

<div class="col-sm-6">
    <form action="login.php" method="post">
    <div class="form-group"></div>
           <label for="username">Username</label>
            <input type="text" name="username" class="form-control">


           <div class="form-group">
           <label for="password">Password</label>
            <input type="password" name="password" class="form-control">


        <input class="btn btn-primary" type="submit" name="submit" value="Submit">
        </div>
    </form>

</div>
    </div>
</body>
</html>

2 Answers2

0

You should close { after die() statement. So it will look like this.

if(isset($_POST['submit'])) {

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


$connection = mysqli_connect('localhost', 'root', 'root', 'loginapp');

    if($connection) {

    echo "We are connected";

    } else {
    }

    die("Database connection failed");
}



?> 
Yasii
  • 1,702
  • 1
  • 10
  • 15
0

problem is you haven't closed your if condition's scope so change the php file like this

<?php  if(isset($_POST['submit'])) {

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


    $connection = mysqli_connect('localhost', 'root', 'root', 'loginapp');

        if($connection) {

        echo "We are connected";

        } else {
        }

        die("Database connection failed");

    } //you are missing this } add it

 ?>
ALPHA
  • 1,135
  • 1
  • 8
  • 18