Reputation: 501
I am trying to make a website that will take data from a html form and add it to a sql database
post.html:
<form action="send_post.php" method="post">
<h3>ID:</h3>
<input type="text" name="id">
<h3>Name:</h3>
<input type="text" name="name">
<h3>Surname:</h3>
<input type="text" name="surname">
<input type="submit">
send_post.php
<?php
$connect = mysqli_connect("myhost","myusername","mypassword","myDB");
mysqli_query($connect,"INSERT INTO test_table (id, name, surname)
VALUES ('$_POST[id]', '$_POST[name]', '$_POST[surname]')"
?>
I have hosted it here
However when I try it says that there is a unexpected semicolon in a line where there is not a semi colon. How do I fix this?
Upvotes: 0
Views: 176
Reputation: 1447
Missing );
Use this...
mysqli_query($connect,"INSERT INTO test_table (id, name, surname)
VALUES ('$_POST[id]', '$_POST[name]', '$_POST[surname]')");
Upvotes: 3