新手前来求指教?为什么这段PHP代码无法注入数据库的表中?

头头不上道 2013-05-12 03:44:17
小白求解各位大神,为什么输不进去啊~~在线急等!!
PHP代码

<?php
$db=mysql_connect("localhost","root","12345") or die("数据库连接失败!");
$sel=mysql_select_db("message",$db) or die("数据库选择失败!");
mysql_query("set names 'GBK'");
$name=$_POST['name'];
$age=$_POST['age'];
$company=$_POST['company'];
$job=$_POST['job'];
$tele=$_POST['tele'];
$email=$_POST['email'];
$beizhu=$_POST['beizhu'];
$myquery="insert into mingpian(id,name,age,company,job,tele,email,beihzu) values ('','$name','$age','$company','$job','$tele','$email','$beizhu')";
$result=mysql_query($myquery,$db);
if($name)
{
echo "<script language=\"JavaScript\">\r\n";
echo " alert(\"添加成功!\");\r\n";
echo " location.replace(\"searchcard.html\");\r\n";
echo "</script>";
}
else
{
echo "<script language=\"JavaScript\">\r\n";
echo " alert(\"添加失败!\");\r\n";
echo " location.replace(\"searchcard.html\");\r\n";
echo "</script>";
}
?>

这是HTML代码

<form name="addcard" id="addcard" method="post" action="addcard.php">
<h1>添加名片</h1>
<fieldset id="inputs">
<input id="name" name="name" type="text" placeholder="姓名" autofocus required>
<input id="age" name="age" type="text" placeholder="年龄" required>
<input id="company" name="company" type="text" placeholder="公司" required>
<input id="job" name="job" type="text" placeholder="职位" required>
<input id="tele" name="tele" type="tel" placeholder="联系电话" required>
<input id="email" name="email" type="email" placeholder="电子邮箱" required>
<input id="beizhu" name= "beizhu" type="text" placeholder="备注" required>
</fieldset>
<fieldset id="actions">
<input type="submit" id="submit" value="添加">
<a href="searchcard.html">返回主页</a>
</fieldset>
</form>
...全文
26 点赞 收藏 回复
写回复
回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
相关推荐
发帖
基础编程
创建于2007-09-28

2.1w+

社区成员

从PHP安装配置,PHP入门,PHP基础到PHP应用
申请成为版主
帖子事件
创建了帖子
2013-05-12 03:44
社区公告
暂无公告