新手前来求指教?为什么这段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>
...全文
67 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

21,887

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧