Video Belajar
Tonton dan pelajari berbagai topik menarik melalui video pembelajaran eksklusif dari Channel Bro Code.
Bro Code
12587
PHP how to insert into MySQL database
#PHP #course #tutorial
include("database.php");
$username = "Patrick";
$password = "rock3";
$hash = password_hash($password, PASSWORD_DEFAULT);
$sql = "INSERT INTO users (user, password)
VALUES ('$username', '$hash')";
try{
mysqli_query($conn, $sql);
echo"User is now registered";
}
catch(mysqli_sql_exception){
echo"Could not register user";
}
mysqli_close($conn);
include("database.php");
$username = "Patrick";
$password = "rock3";
$hash = password_hash($password, PASSWORD_DEFAULT);
$sql = "INSERT INTO users (user, password)
VALUES ('$username', '$hash')";
try{
mysqli_query($conn, $sql);
echo"User is now registered";
}
catch(mysqli_sql_exception){
echo"Could not register user";
}
mysqli_close($conn);