<?php
header("content-type:text/html;charset=gb2312");
$conn=mysqli_connect("locallost","root","root","study");
mysqli_set_charset($conn,"utf-8");
if($conn){
switch($_GET["action"]){
case 'add';
$name=$_POST['name'];
$sex=$_POST['sex'];
$age=$_POST['age'];
$class=$_POST['class'];
$sql="insert into stu(name,sex,age,class)values('$name','$sex','$age','$class')";
$rw=mysqli_query($conn,$sql);
if($rw>0){
echo "<script>alert('add success添加成功');</script>";
}else{
echo "<script>alert('add failure添加失败');</script>";
}
header(‘Location:index.php’);
break;
}
}
?>
What error is reported~
Pay more attention to whether the conditions during link configuration are written incorrectly. For example, password, user name, etc., and check the code for errors