How to create crud in php?

create Database connection

File Name : config.php

<?php
$servername = "localhost";
$username = "username";
$password = "password";
// Create connection
$conn = mysqli_connect($servername, $username, $password);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}



// Check connection
if($conn === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}



// mysqli_close($conn);
?>




/* ********************** OR ***************** */



<?php
$host = "localhost";
$username ="root";
$password = "";
$db_name = "gmax";
$con = mysqli_connect($host,$username,$password) or die(mysqli_error());
mysqli_select_db($con,$db_name)or die(mysqli_error($con));



// mysqli_close($conn);
?>



/* ********************** OR ***************** */



<?php
define ( 'DB_HOST', 'localhost' );
define ( 'DB_USER', 'gmax' );
define ( 'DB_PASSWORD', 'gmaxpass' );
define ( 'DB_NAME', 'gmaxdb' );

$conn = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD) or die('Could not connect to database server.');
mysqli_select_db($conn,DB_NAME) or die('Could not select database.');
?>

File Name :






Previous Next


Trending Tutorials




Review & Rating

0.0 / 5

0 Review

5
(0)

4
(0)

3
(0)

2
(0)

1
(0)

Write Review Here