I'm using oop to insert some data that will be fill from a form into my data base.
I'm able to connet the php to the database using pdo but I'm not having the data going into the database, can you please give me an example.
This is my code:
<?php
class goods
{
public $name_goods;
public $price;
}
try {
$db_conn = new PDO('mysql:host=localhost;dbname=database','root','');
} catch (PDOException $e) {
echo "Could not connect to database";
}
$name_goods = $_POST['name_goods'];
$price = $_POST['price'];
$sql = 'INSERT INTO goods(name_goods, price,)VALUES ($name_goods, $price)';
?>