Skip to content

Instantly share code, notes, and snippets.

@barmgeat
Last active December 27, 2020 21:07
Show Gist options
  • Save barmgeat/6e2e318bd5ba7ada982339e7f385caf7 to your computer and use it in GitHub Desktop.
Save barmgeat/6e2e318bd5ba7ada982339e7f385caf7 to your computer and use it in GitHub Desktop.
add new data to the MySQL Table .
<?php
//insert new data to the table myGuests :
$sql = "INSERT INTO MyGuests (firstname, lastname, email)
VALUES ('John', 'Doe', '[email protected]')";
//check if the statement successfully applicated :
if ($conn->query($sql) === TRUE) {
$last_id = $conn->insert_id;
echo "New record created successfully. Last inserted ID is: " . $last_id;
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
//close the connection to the database :
$conn->close();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment