PHP login registration link database
First we create a conn.php file
The code is as follows:
<?php header("Content-type: text/html; charset=utf-8");//設(shè)置編碼 $con = mysql_connect("localhost","root","root") or die("數(shù)據(jù)庫(kù)連接失敗"); mysql_select_db('login') or die("指定的數(shù)據(jù)庫(kù)不能打開"); mysql_query("set names utf8");//設(shè)置數(shù)據(jù)庫(kù)的字符集 ?>
First we set a character encoding. When there is Chinese in this file, there will be no garbled characters
Then connect to the database
localhost server root username root password
If your server is 127.1.1.1, then you can
$con = mysql_connect("127.1.1.1","Username","Password") or die("Database connection failed");
Open your database, as shown in the fourth line above, database name for login