I am using ampps server for my database. Using php I have written script to connect with server database. Now I want to insert data in the database table.
I tried writing the script and new row is getting inserted with null values.
I tried multiple insert queries but did not succeed.
<?php
require("testDB.php");
class insertUserHelper
{
private $name;
private $email;
private $status;
function insertUserHelper($name,$email,$status)
{
$this -> name = $name;
$this -> email = $email;
$this -> status = $status;
}
function insert()
{
$con = testDatabase::getDB();
echo $name;
echo $email;
echo $status;
$sql = "INSERT INTO user ". "(name,email,status) ".
"VALUES ". "('$name','$email','$status')";
if (mysqli_query($con, $sql)) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($con);
}
}
}
?>
Can anyone help please,very new to php. Thank you..