PHP   

How to add new record in Database using PHP and mysqli

$conn = new mysqli("localhost","root","password","dbname");
if(! $conn ) {
   die('Could not connect to the database ');
}
$userName = "russel";
$userEmail = "[email protected]";
$timestamp = date('Y-m-d H:i:s');

$insertData = "INSERT INTO users (username, email, timestamp) VALUES ('$userName', '$userEmail', '$timestamp')";

if (mysqli_query($conn, $insertData)) {  
	echo "Record added successfully";
} 
else {
	echo "Error adding record: " . mysqli_error($conn);
}
Need a helping hand in fixing your website issues?

If you are facing any problems in implementing these code snippets and tutorials, you can hire us to fix your website issues.

Hire Us