I have a PHP script that is suppose to take values from html form and insert them into a PDO database I do have the tables set. It does not give errors or work.
This is the HTML "form" code:
<form action="latestarticles.php" method="POST">
<input type="text" name="title" value="Title"/>
<input type="text" name="author" value="Author name"/>
<textarea name="content"></textarea>
<input type="datetime-local" name="currentdate" />
<select name="category">
<option value="Sports">Sports</option>
<option value="Local news">Local news</option>
<option value="Technology">Technology</option>
<option value="Business">Business</option>
</select>
<input type="reset" name="reset" value="Reset" />
<input type="submit" name="submit" value="submit" />
</form>
This is the php code latestarticles.php:
<?php
if (isset($_POST['submit'])) {
$stmt = $pdo->prepare("INSERT INTO articles (articletitle, articleauthor, articlecontent) VALUES ($_POST['title'], $_POST['author'], $_POST['content'])");
$stmt->execute();
echo '<p> Successful insert </p>';
} else {
echo '<p> You suck at programming </p>';
}
?>
Thank you for all the help!