表格数据插入到数据库
if($_POST){
$localhost='127.0.0.1';
$r='root';
$p='wuweijian';
$line= mysql_connect($localhost,$r,$p);
mysql_query('set names utf8');
mysql_query('use php2016');
$usename=$_POST['usename'];
$email=$_POST['email'];
@$sex=(int)$_POST['sex'];
$age=(int)$_POST['age'];
$chusheng=$_POST['chusheng'];
$guanji=$_POST['guanji'];
echo $sql="insert into lianxi values(null,$usename,$email,$sex,$age,$chusheng,$guanji)";
// $sql="insert into lianxi values(null,'$usename','$email',$sex,$age,'$chusheng','$guanji')";
$dijiuwanzuoye=mysql_query($sql);
mysql_error();
if($dijiuwanzuoye){
echo '成功';
}else{
echo '失败';
}
}else{
$str="<form action='dijiuwanzuoye.php' method='post'>";
$str.='用户名: <input type=text name="usename" > <br/>';
$str.='性别: <input type="radio" name="sex" value="1"> 男 <input type="radio" name="sex" value="2"> 女 <br/>';
$str.='邮箱: <input type=text name="email"> <br/>';
$str.='年龄:<input type=text name="age">';
$str.='籍贯:<input type=text name="guanji">';
$str.='出生:<input type=text name="chusheng">';
$str.='<input type=submit value="提交">';
$str.="</form>";
echo $str;
}
//数据库
create table lianxi1(
id int unsigned primary key auto_increment,
usename varchar(20),
sex varchar(20),
age int(50),
chusheng int,
guanji varchar(20),
email int
);