有没有先获取客户端的资料
如id=$_POST['id']
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www. xmlns="http://www. http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> </head> <body> <?php ?> <form id="form1" name="form1" method="post" action="save.php"> <table width="400" border="1" cellpadding="0" cellspacing="0"> <tr> <td>姓名:</td> <td><label> <input type="text" name="name" id="name" /> </label></td> </tr> <tr> <td>性别:</td> <td><input name="sex" type="radio" value="1" /> 男 <label> <input type="radio" name="sex" id="radio" value="0" /> 女</label></td> </tr> <tr> <td><p>EMAIL:</p></td> <td><input type="text" name="email" id="email" /></td> </tr> <tr> <td>内容</td> <td><label> <textarea name="info" id="info" cols="45" rows="5"></textarea> </label></td> </tr> <tr> <td colspan="2"><label> <input type="submit" name="button" id="button" value="提交" /> </label></td> </tr> </table> </form> </body> </html>
<?php $name=$_POST['name']; $sex=$_POST['sex']; $email=$_POST['email']; $info=$_POST['info']; $conn=mysql_connect ("localhost", "root", ""); //打开MySQL服务器连接 mysql_select_db("xufan2009"); //链接数据库 mysql_query("set names utf-8"); //解决中文乱码问题 $exec="insert into gbook (name,sex,email,info) values ('" . $name . "','" .$sex . "','" . $email ."','" . $info . "')"; $result=mysql_query($exec); //执行sql语句,返回结果 ?>