<?php
//接收页面
$mysqli=new Mysqli('localhost','root','root','test');
if($mysqli->connect_errno){
die('Connect Error:'.$mysqli->connect_error);
}
@$mysqli->set_charset('utf8');
@$username=$_POST['username'];
@$username=$mysqli->escape_string($username);
@$password=$_POST['password'];
@$age=$_POST['age'];
@$act=$_GET['act'];
@$id=$_GET['id'];
//根据不同的操作完成不同的执行不同代码
//$sql="insert user1(username,password)values('asd','asda')";
switch ($act){
case 'addUser':
$sql="insert user1(username,password,age)values('$username','$password','$age')";
goto query;
break;
case 'delUser':
$sql="delete from user1 where id=$id";
goto query;
break;
case 'editUser':
$sql="update user1 set username='$username', password='$password', age=$age where id=$id";
goto query;
break;
query:
$res=$mysqli->query($sql);
header("location:http://localhost/PHP1/mysqli/userList/userList.php");
}
大写的王