airfling 2020-07-28
<?php //获取数据 $name = $_GET[‘name‘]; $servername = "localhost"; //服务器名 $username = "aaa"; //用户名 $password = "aaa"; //用户密码 $dbname = "bbb"; //数据库名 // 创建连接 $conn = new mysqli($servername, $username, $password, $dbname); // 检测连接 if ($conn->connect_error) { die("连接失败: " . $conn->connect_error); } $sql = "INSERT INTO user (name,time) VALUES (‘$name‘,now())"; if ($conn->query($sql) === TRUE) { echo "新记录插入成功"; } else { echo "Error: " . $sql . "<br>" . $conn->error; } //断开连接 $conn->close(); ?>
红色部分根据实际情况修改