title: Submitting form, mysql and php
body: <p>I'm new to php and sql and all that stuff, and I was watching a tutorial on youtube about forums in php and wonder why this code doesn't echo "Success" when submitting the form. I also wonder why it echo out Failure before I have submitted the form. I have connected successfully to the database.</p>
  
  <pre><code>&lt;!DOCTYPE HTML&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;Register&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;form action="register.php" method="POST"&gt;
              Username: &lt;input type="text" name="username"&gt;
              &lt;br/&gt;
              Password: &lt;input type="password" name="password"&gt;
              &lt;br/&gt;
              Confirm Password: &lt;input type="password" name="confirmPassword"&gt;
              &lt;br/&gt;
              Email: &lt;input type="text" name="email"&gt;
              &lt;br/&gt;
              &lt;input type="submit" name="submit" value="Register"&gt; or &lt;a href="login.php"&gt;Log in&lt;/a&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  &lt;?php
      require('connect.php');
      $username = $_POST['username'];
      $password = $_POST['password'];
      $confirmPassword = $_POST['confirmPassword'];
      $email = $_POST['email'];
  
      if(isset($_POST["submit"])){
          if($query = mysql_query("INSERT INTO users ('id', 'username', 'password', 'email') VALUES('', '".$username."', '".$password."', '".$email."')")){
              echo "Success";
          }else{
              echo "Failure" . mysql_error();
          }
      }
  ?&gt;
  </code></pre>
  
  <p>Connect.php</p>
  
  <pre><code>&lt;?php
  
  $connect = mysqli_connect("localhost", "root", "") or die("Could not connect to server!");
  mysqli_select_db($connect, "php_forum") or die("Could not connect to database!");
  
  ?&gt;
  </code></pre>