我做了个留言板吧,有这些功能,用户登录吗,退出,注册,查看,在线留言等,数据库等也弄好了,其中我 注册成功了,然后登录。。却失败了(密码没错),数据库里没有数据。。哎。不懂啊,我想将我所以的php代码发上了怕不够地方.(不知道可以将压缩文件上传吗?这样大神比较了解下吧)原谅我,没多少分,我是昨晚才开始在scdn活动滴。所以分少了点,等富裕了肯定会有很多分滴。先凑合拿着,帮我解决下。

解决方案 »

  1.   

    用户登录内容:
    <?php
    include "comm.php";
    if(isset($_POST['username'])){
    user_login($_POST['username'],$_POST['pw']);
    }
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
    <HTML xmlns="http://www.w3.org/1999/xhtml">
    <HEAD><TITLE>在线留言-留言板</TITLE>
    <META http-equiv=Content-Type content="text/html; charset=gb2312">
    <STYLE type=text/css>BODY {
    MARGIN: 0px
    }
    </STYLE>
    <LINK href="css/css.css" type=text/css rel=stylesheet>
    <STYLE type=text/css>.STYLE1 {
    FONT-FAMILY: "宋体"
    }
    </STYLE>
    <META content="MSHTML 6.00.2900.6003" name=GENERATOR>
    </HEAD>
    <BODY><TABLE cellSpacing=0 cellPadding=0 width=760 align=center border=0>
      <TBODY>
      <TR>
        <TD
        style="BORDER-RIGHT: #c0c0c0 1px solid; BORDER-LEFT: #c0c0c0 1px solid; BORDER-BOTTOM: #c0c0c0 1px solid"
        vAlign=top width=140 bgColor=#eeeeee>
          <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
            <TBODY>
            <TR>
              <TD class=left_bg2><A class=link3
                href="register.php">用户注册</A></TD></TR>
            <TR>
              <TD class=left_bg2><A class=link3
                href="login.php">用户登录</A></TD></TR>
            <TR>
              <TD class=left_bg2><A class=link3
                href="view.php">查看留言</A></TD></TR>
            <TR>
              <TD class=left_bg1><A class=link2
                href="lyb.php">在线留言</A></TD></TR>
                </TBODY></TABLE>
          <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
            <TBODY>
            <TR>
              <TD><IMG height=288 src="css/25.gif"
          width=140></TD></TR></TBODY></TABLE></TD>
        <TD vAlign=top width=8></TD>
        <TD vAlign=top>
          <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
            <TBODY>
            <TR>
              <TD class=bt>用户登录</TD></TR></TBODY></TABLE>
          <TABLE cellSpacing=0 cellPadding=10 width="100%" border=0>
            <TBODY>
            <TR>
              <TD height=150>
                <TABLE cellSpacing=1 cellPadding=6 width="100%" bgColor=#ff9900
                border=0>
                  <TBODY>
                  <TR>
                    <TD
                    bgColor=#fff2e6>请您登录后提出宝贵的需求、意见和建议,我们会认真及时处理您的留言,并通过电子邮件给您回复。</TD></TR></TBODY></TABLE><BR>
                <TABLE borderColor=#111111 cellSpacing=0 cellPadding=4 width="100%"
                bgColor=#ffffff border=0>
                  <FORM id=myform name=myform action="" method=post>
                  <DIV></DIV>
                  <TBODY>
                  <TR>
                    <TD vAlign=bottom noWrap colSpan=2></TD></TR>
                  <TR>
                    <TD vAlign=bottom noWrap width=70 bgColor=#f7f7f7>用户名:</TD>
                    <TD vAlign=bottom bgColor=#f7f7f7><INPUT id=name size=10
                      name=username></TD></TR>
                  <TR>
                    <TD vAlign=bottom>密码:</TD>
                    <TD vAlign=bottom><INPUT id=pw size=30 type=password name=pw></TD></TR>
                  <TR>
                    <TD><INPUT id=Btn_OK type=image src="css/btn_submit.gif"
                      name=Btn_OK> <A
                      href="http://www.sewworld.com/aboutus/khfk.html#"><IMG
                      onclick=document.myform.reset(); alt=重填
                      src="css/btn_reset.gif" border=0></A></TD></TR></TBODY>
                  <DIV></DIV></FORM></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
    </BODY></HTML>
      

  2.   

    <?php
    include "comm.php";
    session_destroy();
    get_show_msg("login.php","退出登录");
    ?>
      

  3.   

    这个是:判断是否登录成功的吧。
    <?php
    /*
     * Created on 2012-3-29
     *
     * To change the template for this generated file go to
     * Window - Preferences - PHPeclipse - PHP - Code Templates
     */
     session_start();
     include_once("pages.class.php");
     define(ALL_PS,"gdqy");
    function get_show_msg($url, $show = '操作已成功!') {
    $msg = '<!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" />
    <link rel="stylesheet" href="Public/common.css" type="text/css" />
    <meta http-equiv="refresh" content="2; url=' . $url . '" />
    <title>消息提示</title>
    </head>
    <body>
    <div id="man_zone">
      <table width="30%" border="1" align="center"  cellpadding="3" cellspacing="0" class="table" style="margin-top:100px;">
        <tr>
          <th align="center" style="background:#cef">信息提示</th>
        </tr>
        <tr>
          <td><p>' . $show . '<br />
          2秒后返回指定页面!<br />
          如果浏览器无法跳转,<a href="' . $url . '">请点击此处</a>。</p></td>
        </tr>
      </table>
    </div>
    </body>
    </html>';
    echo $msg;
    exit ();
    }function user_login($user,$pw){
    $conn = mysql_connect("localhost","root","15119491321");
    mysql_select_db("lyb");
    $sql = "select * from lyb_user where user_name='$user' and pw='".md5($pw)."'";
    mysql_query("set names 'gb2312'");
    $result = mysql_query($sql,$conn);
    if($row=mysql_fetch_array($result)){
    $_SESSION['uid'] = $row['id'];
    $_SESSION['user'] = $row['user_name'];
    $_SESSION['tele'] = $row['telephone'];
    $_SESSION['email'] = $row['email'];
    $_SESSION['shell'] = md5($row['user_name'].$row['pw'].ALL_PS);
    echo mysql_error();
    get_show_msg("lyb.php","登录成功");
    }else{
    session_destroy();
    get_show_msg("login.php","用户名或密码错误,请重新登录");
    }
    }function user_check($id,$shell){
    $conn = mysql_connect("localhost","root","15119491321");
    mysql_select_db("lyb");
    $sql = "select * from lyb_user where id='$id'";
    mysql_query("set names 'gb2312'");
    $result = mysql_query($sql,$conn);
    if($row=mysql_fetch_array($result)){
    $get_shell = md5($row['user_name'].$row['pw'].ALL_PS);
    if($shell!=$get_shell){
    session_destroy();
    get_show_msg("login.php","无访问权限,请登录");
    }
    }else{ get_show_msg("login.php","非法访问,请登录");
    }
    }?>
      

  4.   

    mysql_query($sql,$conn) or die(mysql_error());
    这样,什么错误都知道了。
      

  5.   

    用户反馈:
    <?php
    include "comm.php";
    user_check($_SESSION['uid'],$_SESSION['shell']);
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
    <HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>在线留言-留言板</TITLE>
    <META http-equiv=Content-Type content="text/html; charset=gb2312">
    <STYLE type=text/css>BODY {
    MARGIN: 0px
    }
    </STYLE>
    <LINK href="css/css.css" type=text/css rel=stylesheet>
    <STYLE type=text/css>.STYLE1 {
    FONT-FAMILY: "宋体"
    }
    </STYLE>
    <script type="text/javascript">
    function check(){ if(myform.title.value==""){
    alert("标题不能为空!");
    return false;
    }
    if(myform.content.value==""){
    alert("留言内容不能为空!");
    return false;
    } return true;
    }
    </script>
    <META content="MSHTML 6.00.2900.6003" name=GENERATOR></HEAD>
    <BODY><TABLE cellSpacing=0 cellPadding=0 width=760 align=center border=0>
      <TBODY>
      <TR>
        <TD
        style="BORDER-RIGHT: #c0c0c0 1px solid; BORDER-LEFT: #c0c0c0 1px solid; BORDER-BOTTOM: #c0c0c0 1px solid"
        vAlign=top width=140 bgColor=#eeeeee>
          <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
            <TBODY>
            <TR>
              <TD class=left_bg2><A class=link3
                href="login.php">用户登录</A></TD></TR>
            <TR>
              <TD class=left_bg2><A class=link3
                href="view.php">查看留言</A></TD></TR>
            <TR>
              <TD class=left_bg1><A class=link2
                href="lyb.php">在线留言</A></TD></TR>
                        <TR>
              <TD class=left_bg2><A class=link3
                href="logout.php?action=logout">退出登录</A></TD></TR></TBODY></TABLE>
          <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
            <TBODY>
            <TR>
              <TD><IMG height=288 src="css/25.gif"
          width=140></TD></TR></TBODY></TABLE></TD>
        <TD vAlign=top width=8></TD>
        <TD vAlign=top>
          <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
            <TBODY>
            <TR>
              <TD class=bt>用户反馈</TD></TR></TBODY></TABLE>
          <TABLE cellSpacing=0 cellPadding=10 width="100%" border=0>
            <TBODY>
            <TR>
              <TD height=350>
                <TABLE cellSpacing=1 cellPadding=6 width="100%" bgColor=#ff9900
                border=0>
                  <TBODY>
                  <TR>
                    <TD
                    bgColor=#fff2e6>感谢您提出的需求、意见和建议,我们会认真及时处理您的留言,并通过电子邮件给您回复。</TD></TR></TBODY></TABLE><BR>
                <TABLE borderColor=#111111 cellSpacing=0 cellPadding=4 width="100%"
                bgColor=#ffffff border=0>
                  <FORM id=myform name=myform action=submit.php method=post onsubmit="return check();">
                  <DIV></DIV>
                  <TBODY>
                  <TR>
                    <TD vAlign=bottom noWrap colSpan=2></TD></TR>
                  <TR>
                    <TD vAlign=bottom width=55>主题:</TD>
                    <TD vAlign=bottom><INPUT id=title size=40 name=title> * </TD></TR>
                  <TR bgColor=#f7f7f7>
                    <TD vAlign=bottom>类型:</TD>
                    <TD vAlign=bottom noWrap height=26><SPAN id=Type><INPUT
                      id=Type_0 type=radio CHECKED value=1 name=type> <LABEL
                      for=Type_0>求助</LABEL> <INPUT id=Type_1 type=radio value=2
                      name=type> <LABEL for=Type_1>建议</LABEL> <INPUT id=Type_2
                      type=radio value=3 name=type> <LABEL for=Type_2>投诉</LABEL>
                      <INPUT id=Type_3 type=radio value=4 name=type> <LABEL
                      for=Type_3>表扬</LABEL> <INPUT id=Type_4 type=radio value=5
                      name=type> <LABEL for=Type_4>业务联系</LABEL> </SPAN></TD></TR>
                  <TR>
                    <TD vAlign=top rowSpan=2>内容:</TD>
                    <TD><TEXTAREA id=content name=content rows=10 cols=50></TEXTAREA>
                      * </TD></TR>
                  <TR>
                    <TD><INPUT id=Btn_OK type=image src="css/btn_submit.gif"
                      name=Btn_OK> <A
                      href="http://www.sewworld.com/aboutus/khfk.html#"><IMG
                      onclick=document.myform.reset(); alt=重填
                      src="css/btn_reset.gif" border=0></A></TD></TR></TBODY>
                  <DIV></DIV></FORM></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
    </BODY></HTML>
      

  6.   

    这个是时间吧:<?php
    echo date("Y-m-d H:m:s");
    ?>
      

  7.   

    判断留言成功否:
    <?php
    /*
     * Created on 2012-3-23
     *
     * To change the template for this generated file go to
     * Window - Preferences - PHPeclipse - PHP - Code Templates
     */
     include_once("comm.php");
     $conn = mysql_connect("localhost","root","15119491321") or die("无法建立连接!"); mysql_select_db("lyb") or die(mysql_error()."数据库无法打开"); $title = $_POST['title']; $type = $_POST['type']; $content = $_POST['content']; $date_time = date("Y-m-d H:m:s"); $author = $_SESSION['user']; if($content!="" and $title!=""){
    $sql = "insert into lyb_table (subject,type,content,publish_time,author) values('$title','$type','$content','$date_time','$author')";
    mysql_query("set names 'gb2312'");
    mysql_query($sql,$conn);
    get_show_msg("lyb.php","留言成功!");
     }else{
      get_show_msg("lyb.php","留言填写错误,请重新填写!");
     } mysql_close($conn);
    ?>