Heim > Fragen und Antworten > Hauptteil
<?php
header("content-type:text/html;charset=gb2312");
$conn=mysqli_connect("locallos","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=" hineinstecken 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 fail添加失败');</script>";
}
header('Location:index.php');
break;
}
}
?>