<?php //设置编码格式 header("Content-type:text/html;charset=utf-8"); //设备变量 $servername = "localhost"; $username = "root"; $password = "root"; $dbname = "test"; //获取传递值:$_GET['name'] 或$_POST['name'] $id = $_GET['id']; $name = $_GET['name']; $age = $_GET['age']; $sex = $_GET['sex']; // 创建连接 $con =mysqli_connect($servername, $username, $password, $dbname); $sql="INSERT INTO `表名称`(`字段1`, `字段2`, `字段3`, `字段4`) VALUES ("$id","$name","$age","$sex")"; $result = mysqli_query($con,$sql); if($result) echo "添加成功!"; else echo "添加失败!"; mysqli_close($con); ?>