I'm trying to get the hang of PDO and I can't seem to get this to work. I'm tyring to insert some data into a databse, but nothing shows up when I click submit. What am I doing wrong?
<?php
require 'connect.php';
if (isset($_POST['username'], $_POST['password'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$insert = "INSERT INTO `register` (`username`, `password`) VALUES(:username, :password)";
if (!empty($username) && !empty($password)) {
$query_run = $db->prepare($insert);
$query_run->execute( array(':username' => $username, ':password' => $password) );
} else {
echo 'Error';
}
}
?>
<form action="index.php" method="POST">
<input type="text" name="username"/>
<input type="password" name="password"/>
<input type="submit" value="Submit"/>
</form>