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");//设置编码 $con = mysql_connect("localhost","root","root") or die("数据库连接失败"); mysql_select_db('login') or die("指定的数据库不能打开"); mysql_query("set names utf8");//设置数据库的字符集 ?>
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