我用的是PHP storm,phpstudy的环境,数据库是用的 phpMyAdmin
php
<?php
header("Content-Type:text/html;charset=utf-8");
$username = $_POST['username'];
$pw = $_POST['pw'];
$cpw = $_POST['cpw'];
$sex = $_POST['sex'];
$email =$_POST['email'];
$fav = @implode(",",$_POST['fav']);
//连接数据库
$conn = mysqli_connect("localhost","root","20031022","member");
mysqli_query($conn,"set names utf8");
//sql语句
$sql = "insert into info(username,pw,sex,email,fav,creatime) values('$username','".md5($pw)."','$sex','$email','$fav','".time()."')";
$result = mysqli_query($conn,$sql);
if($result){
echo"<script>alert('数据插入成功')</script>";
}else{
echo "<script>alert('数据插入失败')</script>";
}
?>