php - register including post fail


I am trying to build a login system with registration etc. now for the registration i use a form and the method "post". Now it fails in what i think is sending the input trough the post. can you help me fix it? here is the code involved in it:

above !doctype

// If the values are posted, insert them into the database.
if (isset($_POST["username"]) && isset($_POST["password"])){
    $username = $_POST["username"];
    $email = $_POST["email"];
    $password = $_POST["password"];

    $query = "INSERT INTO `user` (username, password, email) VALUES ($username, $password, $email)";
    $result = mysqli_query($query);
        $msg = "User Created Successfully.";
  {echo "fail";}

the form:

<div class="register-form">
if(isset($msg) & !empty($msg)){
    echo $msg;
<form action="" method="POST">
<p><label>User Name : </label>
<input id="username" type="text" name="username" placeholder="username" /></p>

<p><label>E-Mail&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : </label>
 <input id="password" type="email" name="email" required placeholder="[email protected]" /></p>

 <p><label>Password&nbsp;&nbsp; : </label>
 <input id="password" type="password" name="password" placeholder="password" /></p>

<a href="login.php">Login</a>
<input type="submit" name="submit" value="Registreer" />


The connect.php

$servername = "localhost";
$username = "sqluser";
$password = "Welkom01!";
$dbname = "users";

$connection = mysqli_connect($servername, $username, $password);
if (!$connection){
die("Database Connection Failed". mysqli_error($connection));
$select_db = mysqli_select_db($connection, $dbname);
if (!$select_db){
die("Database Selection Failed" . mysqli_error($connection));

Thanks in advance.

People are also looking for solutions to the problem: php - Return a variable from a function to a view


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.