左右两边都是两个下划线,注意啊
<?php if($_POST['submit'] == '提交'){ $servername = "localhost"; //数据库链接地址 $username = "root"; //数据库用户名 $password = ""; //数据库密码 // 创建连接 $conn = new mysqli($servername, $username, $password, $dbname = "test",$port = 3333); // 检测连接 if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } //设置编码模式 $conn->query("SET NAMES UTF8"); //把数据插入到数据库 $sql = "INSERT INTO user (name, password) VALUES ('".$_POST['name']."', '".md5(md5(md5($_POST['password'])))."')"; //输出SQL语句 print_r($sql); //判断是否插入成功 if ($conn->query($sql) === TRUE) { echo "写入数据库成功"; } else { echo "写入失败: " . $sql . "<br>" . $conn->error; } $conn->close(); } ?>