I have a simple html form set up with one field "name" and then submit.
I'm trying to be able to input name and hit submit, have it go to separate form handling page, which will then use php to input data into my database and table.
I have about 99% correct, it even worked once. Then for some reason it didn't upon my next entry.
My html form is form.html and my form handling page is fh.php
The fh.php page simply references another php page for connection and that's all working fine.
My table is called "articles"
Here's my form.html page code
<html>
<body>
<form action="fh.php" method="post">
Name: <input type="text" name="name">
<br>
<input type="submit" value="INSERT">
</form>
</body>
</html>
and here's my fh.php page:
<?php
include_once('dbconnect.php');
if($debugMode){
var_dump($_POST);
}
$name = $_POST['name'];
$sql = "INSERT INTO articles (name) VALUES ('$name')";
if(!mysqli_query ($link,$sql))
{
echo 'Not Inserted';
}
else
{
echo 'Inserted';
}
header("refresh:2; url=form.html");
?>
And then finally, here's FH page will load briefly and say:
Success: A proper connection to MySQL was made! The my_db database is great. Host information: 127.0.0.1 via TCP/IP array(1) { ["name"]=> string(5) "sdfsd" } Not Inserted
Then refreshes and goes back to my form page and the entry isn't made. Any help would be greatly appreciated. My sql db is running on MAMP and is all working fine.