I am new at web developing and I am still practicing. I have searched all possible answers to help me with my problem, but I still cannot insert my data to the database. I am using XAMPP version 3.2.2 and Sublime editor.
Here is my HTML form:
and here is the PHP (inserting.php)
$user = 'root';
$pass = '';
$db = 'sample';
$con = mysqli_connect('localhost', $user, $pass, $db);
if($con){
echo 'success!';
}else echo 'not successful';
$sql = "insert into nameinfo (fname, lname) values ($_POST[fname],
$_POST[lname])";
$query = mysqli_query($con,$sql);
if ($query) {
echo 'good';
}else echo 'not good';
?>
When I run it, the connection succeeds, but it's not able to insert. Please help, thank you.
No comments:
Post a Comment