Last active
April 7, 2019 15:32
-
-
Save A-Kiwams/2bcd87040acee46407618bff4822f9ef to your computer and use it in GitHub Desktop.
Backend Newbie1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header("Access-Control-Allow-Origin: *"); | |
header("Access-Control-Allow-Methods: PUT, GET, POST, DELETE"); | |
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept"); | |
//Database credentials | |
define('DB_HOST', 'localhost'); | |
define('DB_USER', 'root'); | |
define('DB_PASS', 'YOUR_PASSWORD'); | |
define('DB_NAME', 'mydb'); | |
//Connect to database | |
function connect() | |
{ | |
$connect = mysqli_connect(DB_HOST ,DB_USER ,DB_PASS ,DB_NAME); | |
if (mysqli_connect_errno($connect)) { | |
die("Failed to connect:" . mysqli_connect_error()); | |
} | |
mysqli_set_charset($connect, "utf8"); | |
return $connect; | |
} | |
$con = connect(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment