Can anyone tell me what am I doing wrong here? I am new to PDO and need to learn how to insert using bindValue but nothing is been added to my database when I hit submit. Not even an error is shown.
Can anyone give an example. Below is my code:
<!DOCTYPE html>
<html lang="eng">
<head><title>PDO INSERT TEST</title>
<meta http-equiv="CONTENT-TYPE" CONTENT="text/html;charset=utf-8"/>
</head>
<body>
<form action="PDO_test1.php" method="POST">
<p>Name: <input type="text" name="userName" id="Name"/></p>
<p>Last: <input type="text" name="userLast" id="Last"/></p>
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>
<?php 
    # basic pdo connection (with added option for error handling)
    if (isset($_POST['submit'])) {
        require_once 'includes/PDO_connect.php';
        try {
            $dsn = "mysql:host=$servername;dbname=$dbname";
            $dbc = new PDO($dsn, $username, $password);
            //You can echo out connected to db message
            $dbc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            $query = $dbc->prepare("INSERT INTO `PdoTest1` (userName,userLast,reqistration_date) VALUES (?, ?, ?)");
            # If we leave out the third parameters, it is set to
            # PDO::PARAM_STRING by default
            $query->bindValue(':userName', '%' . $_POST['userName'] . '%');
            $query->bindValue(':userLast', '%' . $_POST['userLast'] . '%');
            $dbc = null;
        }
        catch (PDOException $e) {
            echo $e->getMessage();
        }
        //echo "<p>Data submitted successfully</p>";
    }
?>
 
     
    