//向数据库添加数据(form表单提交)

时间:2022-10-13 16:35:09

<?php
header( 'Content-Type:text/html;charset=utf-8 ');
 include_once("conn/conn.php");
 $name=$_POST["name"];
 $password=$_POST["password"];
 $sex=$_POST["sex"];
 $college=$_POST["college"];
 $class=$_POST["class"];
 $tel=$_POST["tel"];
 $sql="INSERT into user(name,password,sex,college,class,tel) values ('$name','$password','$sex','$college','$class','$tel') " ;
 $r=mysqli_query($link,$sql);
 if($r){
   echo "<script>alert('写入成功');history.back();</script>";
 }else{
  echo "写入失败";
 }
?>