连接db php

时间:2018-03-03 21:44:16

标签: php database

我是php新手。如果代码错误,请不要怪我。所以我正在尝试连接到db,但是.....错误:“解析错误:语法错误,D:\ xampp \ htdocs \ demo \ mysql \ login.php在第40行意外结束文件” 我正在使用MAMP。 有代码:

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

    $username = $_POST['username'];
    $password = $_POST['password'];
    $connection = mysqli_connect('localhost', 'root', 'root', 'loginapp', 8889);    
        if($connection) {
            echo "yep";
        } else {
            die("nop");
        }
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <!-- bootstrap -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
    <!-- /bootstrap -->
</head>
<body>
<div class="container">
    <div class="col-sm-6">
        <form action="login.php" method="post">
            <div class="form-group">
               <label for="username">Username</label>
                <input type="text" name="username" class="form-control">
            </div>
            <div class="form-group">
                <label for="password">Password</label>
                <input type="password" name="password" class="form-control">
            </div>
            <input class="btn btn-primary" type="submit" name="submit" value="Submit">
        </form>
    </div>
</div>
</body>
</html>

0 个答案:

没有答案