how to insert data using php - LET'S BE CREATIVE

how to insert data using php


$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";

// Create connection$conn = new mysqli($servername, $username, $password, $dbname);
// Check connectionif ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 

$sql = "INSERT INTO MyGuests (firstname, lastname, email)
VALUES ('AR', 'KHAN', 'ARKHAN0727@GMAIL.com')"
;

if ($conn->query($sql) === TRUE) {
    echo "New record created successfully";
else {
    echo "Error: " . $sql . "
"
 . $conn->error;
}

$conn->close();
?>


Featured