Connect webpage to database using PHP

11.5.3.4 use script language to connect a database

Connect webpage to database using PHP

Scenario 
 

The school holds competitions among Shanyrak. For each useful action, Shanirak points are scored. The deputy director keeps a record of all the items in the notebook. Counting and identifying all points takes a long time, and there may be errors. Automate the work. 

Database Scenario 

Users (userID, username, userlogin, userpassword, userstatus)
Shanyraks (shanID, userID, shanname)
Competitions (comID, userID, shanID, comname, comdate, compoints)

How to create Database MySQL

Use PHP and MySQLi to connect with database Scenario

Create file connect.php in folder Project (in htdocs).

<?php

$servername = "localhost";  // name of server
$username = "username";     // name of user
$password = "password";     // password of user

$db = "scenario"; // name of database in phpMyAdmin

// Create connection
$conn = mysqli_connect($servername, $username, $password, $db);

// Check connection
if (!$conn) {  // if connection False
  die("Connection failed: " . mysqli_connect_error());  // show message about error connection and stop php script
}
echo "Connected successfully"; // show message if connection True

?>

 

Категория: Relational databases | Добавил: bzfar77 (25.01.2021)
Просмотров: 30 | Теги: webpage, Connect, php, database | Рейтинг: 5.0/1
Всего комментариев: 0
avatar