I'm trying to insert data into a Webmin MySQL Database, but every time I hit submit on my form, It doesn't put the information in the MySQL database. I ran a test and it's running all the way to the INSERT part but it still didn't put anything in the DB. I can read from it just fine, but I can't write to it. I have all the permissions, but it still doesn't work. It also get all of the variables ($tblusername, $tblemail, $tblpassword). Here's my PHP (I'm using PDO.) Please help!
<?php
if(isset($_POST['submit'])) {
try {
$tblusername = $_POST['Username'];
$tblemail = $_POST['Email'];
$tblpassword = $_POST['Password'];
$conn = new PDO("mysql:host=$servername;dbname=mealplan", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT UserName FROM tblUsers");
$stmt->bindParam(1, $tblusername, PDO::PARAM_STR);
$stmt->execute();
if($stmt->rowCount() > 0){
die("Username already in use!");
}else{
$sql = "INSERT INTO `tblUsers` (`UserName`, `Email`, `UserPassword`) VALUES ($tblusername, $tblemail, $tblpassword)";
$stmt = $conn->prepare($sql);
$stmt->execute();
}
} catch(PDOException $e) {
echo "<style>.hidden { visibility: visible; } .shown { visibility: hidden; font-size: 0px }</style>";
}
}
?>