已有40人关注
php开发典型模块大全第5章
发表在PHP图书答疑 2010-04-06
是否精华
版块置顶:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
 <form action="houtai_ok.php" method="post" name="form1" id="form1" onSubmit="return check_input(form1)">
                                  <tr>
                                    <td height="30" colspan="3">&nbsp;</td>
                                  </tr>
                                  <tr>
                                    <td width="106" height="30" align="right" class="STYLE11">歌名:</td>
                                    <td width="674" height="30" colspan="2">&nbsp;
                                        <input name="tb_forum_music" type="text" class="inputcss" id="tb_forum_music" size="55" />
                                        &nbsp;</td>
                                  </tr>
                                  <tr>
                                    <td height="30" align="right" class="STYLE11">歌手:</td>
                                    <td height="30" colspan="2">&nbsp;
                                    <input name="tb_forum_geshou" type="text" id="tb_forum_geshou" size="55"></td>
                                  </tr>
                                  <tr>
                                    <td height="30" align="right" class="STYLE11">歌曲路径:</td>
                                    <td height="30" colspan="2">&nbsp;
                                        <input name="tb_forum_lujing" type="text" id="tb_forum_lujing" size="55" />
                                      &nbsp;</td>
                                  </tr>
                                  <tr>
                                    <td height="50" colspan="3"><div align="center">
                                        
                                                                       <input type="submit" name="submit"  value="提交注册信息" />
                                      &nbsp;&nbsp;
                                      <input name="reset" type="reset"  value="重新填写注册信息" />
                                    </div></td>
                                  </tr>
                                </form>
</table>



</body>
</html>
这是处理页面

<?php 
include_once("conn/conn.php");
$tb_forum_music=trim($_POST[tb_forum_music ]);
$sql=mysql_query("select tb_forum_music from tb_forum_music where tb_forum_music='$tb_forum_music'",$conn);
$info=mysql_fetch_array($sql);
if($info!=false){
  echo "<script language='javascript'>alert('对不起,该歌曲已经添加!');history.back();</script>"; 
  exit; 
}
$tb_forum_music=trim($_POST[tb_forum_music]);
$tb_forum_geshou=trim($_POST[tb_forum_geshou]);
$tb_forum_lujing=trim($_POST[tb_forum_lujing]);
$tb_forum_date=date("Y-m-d h:i:s");
$tb_forum_id=1;

$query=mysql_query("insert into 
tb_forum_music(tb_forum_music,tb_forum_geshou,tb_forum_type,tb_forum_lujing,tb_forum_date,) 

values('$tb_forum_music','$tb_forum_geshou','$tb_forum_lujing','$tb_forum_type','$tb_forum_date',)",$conn);
if($query==true){ 
session_register("tb_forum_music");
   $_SESSION["tb_forum_music"]=$tb_forum_user; 
echo "<script>alert('注册成功!');window.location.href='index.php';</script>";
}else{
   echo "<script language='javascript'>alert('对不起,注册失败!');history.back();</script>"; 
   exit;
}
?>
这是数据库

tb_forum_id  int(10) 否      
tb_forum_geshou  varchar(50) 否      
tb_forum_lujing  varchar(100) 否      
tb_forum_date  datetime 否      
tb_forum_music  varchar(50) 否      

索引: 
键名 类型 唯一 紧凑 字段 基数 整理 空 注释 
PRIMARY BTREE 是 否 tb_forum_id 0 A   


已用空间: 类型 已用 
数据 0 字节 
索引 1,024 字节 
总计 1,024 字节 
   行统计: 说明 值 
格式 动态  
行数 0  
创建时间 2010 年 04 月 06 日 00:48  
最后更新 2010 年 04 月 06 日 00:48  
 

为什么我想往里面注册 总是注册失败那 ......

分享到:
精彩评论 1
346827366
学分:0 LV1
2010-04-08
沙发
在这个语句“if($query==true){ ”的前面增加一个语句输出错误信息:

echo mysql_error();

看一下具体是那里的问题
首页上一页 1 下一页尾页 1 条记录 1/1页
手机同步功能介绍
友情提示:以下图书配套资源能够实现手机同步功能
明日微信公众号
明日之星 明日之星编程特训营
客服热线(每日9:00-17:00)
400 675 1066
mingrisoft@mingrisoft.com
吉林省明日科技有限公司Copyright ©2007-2022,mingrisoft.com, All Rights Reserved长春市北湖科技开发区盛北大街3333号长春北湖科技园项目一期A10号楼四、五层
吉ICP备10002740号-2吉公网安备22010202000132经营性网站备案信息 营业执照