I know this is probably something very easy for most of you but I am learning PHP/PDO and trying to get a simple guest book working. The problem I am having is that I am not getting my date to insert into the database as I want it too. Basically it is just an html form that has name and a comment field, when the user fills those out and presses submit it goes to my php file which is supposed to insert into the database, the only problem is that I have not got it to insert anything at all, I've tried searching the internet for advice and help but nothing I found works. All of my question I've asked here have been answered so I figured I'd give it another go. Here are all the pieces of the code.
HTML:
PHP:
I have tried multiple values in the "date" area as well as $Date and the ...bindPara(2,$Date); area... I also switched out the ? where Values is. I can't get anything to work. I've literally tried over a hundred things with no results. Here is a picture of the database:
I realize this is probably something relatively easy but I can't get it. Thanks in advance.
HTML:
HTML:
<HTML>
<head>
<title>Simple Comment Page To Use PDO</title>
</head>
<body>
<form action="guest.php" method="post">
<label>Enter Your Name</label><input type="text" name="uname" id="uname"></input>
<br>
<label>Enter Your Comment</label>
<input type="textbox" name="cmmt" id="cmmt"></input><br>
<input type="submit" value="Register" />
</form>
</body>
</html>
PHP:
PHP:
<?php
$dbh = new PDO('mysql:host=localhost;dbname=test', 'dbAdmin', '###########');
$stmt = $dbh->prepare("insert into TestGuest(Name, Date, Comment) values (?,?,?)");
$stmt->bindParam(1, $Name);
$stmt->bindParam(2, $Date);
$stmt->bindParam(3, $Comment);
$Name = $_POST["uname"];
$Date = $_POST["date"];
$Comment = $_POST["cmmt"];
$stmt->execute();
echo "<p>Your Comment has been added.</p>";
?>
I have tried multiple values in the "date" area as well as $Date and the ...bindPara(2,$Date); area... I also switched out the ? where Values is. I can't get anything to work. I've literally tried over a hundred things with no results. Here is a picture of the database:
I realize this is probably something relatively easy but I can't get it. Thanks in advance.