PHP代码还有数据库我会发上来,经过很多次研究还是弄不来所以只有求救了, 数据库文件-- phpMyAdmin SQL Dump
-- version 2.11.2.1
-- http://www.phpmyadmin.net
--
-- 主机: localhost
-- 生成日期: 2012 年 06 月 6 日 06:59
-- 服务器版本: 5.0.45
-- PHP 版本: 5.2.5SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";--
-- 数据库: `aaa`
---- ----------------------------------------------------------
-- 表的结构 `text`
--CREATE TABLE `text` (
  `id` int(11) NOT NULL auto_increment,
  `title` char(50) NOT NULL,
  `content` char(100) NOT NULL,
  `paotdate` datetime NOT NULL,
  `huitie` char(100) default 'null',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=gb2312 AUTO_INCREMENT=3 ;--
-- 导出表中的数据 `text`
---- ----------------------------------------------------------
-- 表的结构 `username`
--CREATE TABLE `username` (
  `id` int(11) NOT NULL auto_increment,
  `username` char(50) NOT NULL,
  `password` char(50) NOT NULL,
  `date` datetime NOT NULL,
  `usertext` char(50) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=gb2312 AUTO_INCREMENT=2 ;--
-- 导出表中的数据 `username`
--
PHP代码:
conn.php:(php文件名下面一样的)<?php
  $conn=@mysql_connect('localhost','root','')or die("数据库未连接");
  mysql_select_db('aaa',$conn);
  mysql_query('SET NAMES gb2312');
?>
content.php:
<?php
session_start();
$name=$_SESSION['username'];
  if(!$_SESSION['isLogin'])
  {
   header('location: ./record.php');
  }
  else
  {
  echo "用户:".$_SESSION['username']."你好,欢迎光临!<br>";
  }
include('conn.php') ;
$sql = stripslashes("select * from text where id=".$_GET['id']."") ;
$result = mysql_query($sql) ;
$row = mysql_fetch_array($result);
if($row){
?>
<table width="800" border="0" cellspacing="0" cellpadding="0">
<tr>
  <td >标题:</td>
  <td><?php echo $row['title']?></td>
</tr>
<tr>
  <td >正文:</td>
  <td height="200"><?php echo $row['content']?></td>
</tr>
<tr>
  <td>时间:</td>
  <td><?php echo $row['paotdate']?></td>
</tr>
<tr>
  <td>回帖:</td>
  <td><?php echo $row['huitie']?></td>
  
</tr>
<tr>
<td></td>
<td><?php echo "<a href=search.php?id='".$row['id']."'>回帖</a>" ;?></td>
</tr>
<?php
}
?>
</table>delete.php:
<?php
  session_start();
  $name=$_SESSION['username'];
  if(!$_SESSION['isLogin'])
  {
   header('location: ./record.php');
  }
include('conn.php') ;
$sql = stripslashes("delete from text where id=".$_GET['id']."") ;
mysql_query($sql) ;
mysql_close($conn) ;
header("location: index.php") ;
?>index.php:
<?php
  session_start();
  echo $_SESSION['username'];  $name=$_SESSION['username'];
  if(!$_SESSION['isLogin'])
  {
   header('location: ./record.php');
  }
  else
  {
  echo "用户:".$_SESSION['username']."你好,欢迎光临!<br>";
  }
  if(isset($_POST['button']))
  {
  include('conn.php');
  $sql="delete from text where username='$name'";
      $quers=mysql_query($sql) ;  }
?><html>
<head>
<title>论坛</title>
<link href="mystyle.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<p align="right">
<a href="index.php" >主页</a>
<a href="tribune.php" >发表</a>
<a href="quit.php" >退出</a><br>
</p>  
<table border="1">
<tr>
    <td width="20">ID</td>
    <td width="300">标题</td>
<td width="380">回帖</td>
    <td width="100">时间</td>
    <td></td>
    <td></td>
<td></td>
<td></td></tr><?php
include('conn.php') ;
$sql = "select * from text" ;
$result = mysql_query($sql) ;
while($row = mysql_fetch_array($result)){
?><tr>
    <td width="20"><?php echo "<a href=content.php?id='".$row['id']."'>".$row['id']."</a>" ;?></td>
    <td width="300"><?php echo $row['title'] ;?></td>
<td width="380"><?php echo $row['huitie'] ;?></td>
    <td width="100"><?php echo $row['paotdate'] ;?></td>
    <td><?php echo "<a href=update.php?id='".$row['id']."'>修改</a>" ;?></td>
    <td><?php echo "<a href=delete.php?id='".$row['id']."'>删除</a>" ;?></td>
<td><?php echo "<a href=content.php?id='".$row['id']."'>查看</a>" ;?></td>
<td><?php echo "<a href=search.php?id='".$row['id']."'>回帖</a>" ;?></td></tr>
<?php   
}
?>
</table>
<form>
<input type="text" name="search"><input type="submit" name="search" value="查找">
</form>
</body>
</html>quit.php:<?php
  session_start();
  $name=$_SESSION['username'];
  $_SESSION=array();
 echo "用户:".$name."不要忘了我们哦!<br>";?><a href="record.php">重新登陆</a>record.php:
<?php
   include('conn.php');
   if(isset($_POST['button']))
   {
   $username=$_POST['name'];
   $pass=$_POST['pass'];
   $sql="SELECT * FROM username WHERE username='$username' AND password='$pass'";
   $query=mysql_query($sql);
   $row=mysql_fetch_array($query);
   if($row)
   {
   session_start();
   $_SESSION['username']=$username;
           $_SESSION['isLogin']=true;
   header('location: ./index.php');
   }
   if(empty($username) || empty($pass))
    {  
  if(empty($username))
echo '<script>alert("用户名不能为空!")</script>';
  if(empty($pass))
echo '<script>alert("密码不能为空!")</script>';
    }
  else
{
$sql_1="SELECT * FROM username WHERE username='$username'";
$query=mysql_query($sql_1);
$array=mysql_fetch_array($query);
if($array)
           echo '<script>alert("用户'.$username.'密码不正确!")</script>';
else
                    echo '<script>alert("用户不存在,请注册!")</script>';
    }       }
   if(isset($_POST['button2']))
   {
       header('location:./reg.php');   }?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html charset=gb2312" />
<title>登陆</title>
<style type="text/css">
.tr1 {
background-color: #FFF;
border-top-style: outset;
border-right-style: outset;
border-bottom-style: outset;
border-left-style: outset;
border-top-color: #0CF;
border-right-color: #0CF;
border-bottom-color: #0CF;
border-left-color: #0CF;
}
.tr2 {
background-color: #CCC;
border: thin dotted #999;
}
.tr2 #form1 .td1 {
border: thin inset #09C;
}
</style>
</head><body>
<table width="100%" height="684" cellspacing="0">
  <tr  class="tr1">
    <td width="27%" rowspan="4">&nbsp;</td>
    <td width="40%" height="105"><p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p></td>
    <td width="33%" rowspan="4">&nbsp;</td>
  </tr>
  <tr class="tr2">
  <form  action="record.php" method="post" >
    <td height="195" class="td1">   
      
        欢迎用户进入我们的论坛!<br><br>
      &nbsp;&nbsp;&nbsp;&nbsp;<label for="name">用户名:</label>
        <input type="text" name="name" id="name" />
  
        <br><br>
          &nbsp;&nbsp;&nbsp;&nbsp;<label for="password">密&nbsp;&nbsp;&nbsp;码:  </label>
          <input type="password" name="pass" id="pass" />
        <br><br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          
          <input type="submit" name="button" id="button" value="登陆"/> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <input type="submit" name="button2" id="button2" value="注册" />
    </form>
        <br></td>
  </tr>
  <tr class="tr1">
    <td height="290">&nbsp;</td>
  </tr>
  <tr class="tr1">
    <td>&nbsp;</td>
  </tr>
</table>
</body>
</html>

解决方案 »

  1.   

    接上面的因为太长了,
    reg.php:
    <?php
     include('conn.php');
     
    if(isset($_POST['button2']))
    {
       header('location: ./reg.php');
    }

    if(isset($_POST['button']))
    {
    include('conn.php');
    $username=$_POST['name'];
    $pass1=$_POST['pass1'];
    $pass2=$_POST['pass2'];
    $date=$_POST['year'].'-'.$_POST['month'].'-'.$_POST['day'];
    $usertext=$_POST['usertext'];
    $sql="SELECT * FROM username WHERE username='$username'";
    $query=mysql_query($sql);
    $array=mysql_fetch_array($query);
    $row=mysql_fetch_row($query);
    if($array)
    {
    echo '<script>alert("用户名已存在!")</script>';
    }
        else
    {
    if( $pass1 != $pass2 )
    {
               echo '<script>alert("两次密码有误!")</script>';
    }
    else
    {
    if(empty($pass1) )
    {
     echo '<script>alert("密码不能为空!")</script>'; }
    else
    {
    $sql_1="INSERT INTO username(username,password,date,usertext) VALUES('$username','$pass1','$date','$usertext')";
    $query=mysql_query($sql_1);
        if($query)
        {
                     header('location: ./record.php');
         }
    }

    } }}
    ?><! DOCTYPE html PUBLIC"-//W3C//DTD XHTML1.0Transitional//EN""http: //www.w3.org/TR/xhtml1/DTD/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>
    <link href="mystyle.css" rel="stylesheet" type="text/css"/>
    </head>
    <body><p align="center">用户注册</p><form action="reg.php" method="post" enctype="multipart/from-data" name="from1" id="from1">   <table width="563" border="0" align="center" cellspacing="1" bgcolor="#79A6D1">
           <tr bgcolor="#FFFFFF">
         <td  >姓名:</td>
     <td colspan="2">
       <label><br>
           <input type="text" name="name" id="name"/></label>
       *必填上4~6个字符  </td>
       </tr>
       <tr bgcolor="#FFFFFF">
         <td>电子邮箱:</td>
     <td colspan="3">
        <label><input type="text" name="email" id="email"/>
        *必须填上合法的电子邮箱
    </label>
     </td>
       </tr>
       <tr bgcolor="#FFFFFF">
         <td>用户密码:</td>
     <td colspan="2">
        <label><input type="password" name="pass1" id="pass1"></label>
        *与确认密码保持一致         </td>
        </tr>
       <tr bgcolor="#FFFFFF">
         <td>确认密码:</td>
     <td colspan="2">
        <input type="password" name="pass2" id="pass2">
             </td>
        </tr>
    <tr bgcolor="#FFFFFF">
         <td>&nbsp;</td>
     <td colspan="2">
        <p>
             </td>
        </tr>

    <tr bgcolor="#FFFFFF">
         <td>性别:</td>
     <td colspan="2">
        <label><select name="sex" id="sex">
             <option value="男">男</option>
         <option value="女">女</option>
       </select>
    </label>
             </td>
        </tr>
              
    <tr bgcolor="#FFFFFF">
         <td>婚否:</td>
     <td colspan="2">
        <label><input type="radio" name="marriage" id="marriage" value="已婚"/>已婚
           <input type="radio" name="marriage" id="marriage2" value="未婚"/>未婚
       </select>
    </label>
             </td>
        </tr>
    <tr bgcolor="#FFFFFF">
         <td>出生日期:</td>
     <td colspan="2">
        <label><input type="text" name="year" id="year" size="4" maxlength="4"/>年
           <input type="text" name="month" id="month" size="2" maxlength="2"/>月
       <input type="text" name="day" id="day" size="2" maxlength="2"/>日
       </select>
       *日期要合法
    </label>
             </td>
        </tr>
           <tr bgcolor="#FFFFFF">
         <td>兴趣爱好:</td>
     <td colspan="2">
        <label><input type="checkbox" name="favorites" id="favorites" value="阅读" checked="checked"/>阅读
           <input type="checkbox" name="favorites" id="favorites" value="音乐" checked="checked"/>音乐
       <input type="checkbox" name="favorites" id="favorites" value="旅游" checked="checked"/>旅游
       <input type="checkbox" name="favorites" id="favorites" value="游泳" checked="checked"/>游泳
       </select>
    </label>
             </td>
        </tr>
    <tr bgcolor="#FFFFFF">
       <td>照片上传:</td>
       <td colspan="2">
                    <label>
      <input type="file" name="upfile" id="upfile">
    </label>
         </td>
     </tr>
    <tr bgcolor="#FFFFFF">
       <td height="102">个人描述:</td>
       <td colspan="2">
                    <label>
      <textarea name="usertext" cols="20" rows="5" id="content">请输入你的个人介绍!让我们更了解你!</textarea>
    </label>
         </td>
     </tr>
            <tr bgcolor="#FFFFFF">
       <td>&nbsp;</td>
       <td width="156">
      <input type="submit" name="button" id="button" value="提交">

         </td>
       <td width="302">
      <input type="reset" name="button2" id="button2" value="取消">
         </td>
     </tr>
     </form>
             </table>  
    </body>
    </html>search.php:
    <?PHP
      session_start();
      $name=$_SESSION['username'];
      if(!$_SESSION['isLogin'])
      {
       header('location: ./record.php');
      }
      else
      {
      echo "用户:".$_SESSION['username']." 你好!欢迎光临!<br>";
      }
      if(isset($_POST['submit']))
      {
      include('conn.php') ;
      $sql = "update text set  huitie='".$_POST['huitie']."' where id='".$_POST['id']."'" ;
      mysql_query($sql) ;
      mysql_close($conn) ;
          header('location: ./index.php');  }
    include('conn.php') ;
    $sql =stripslashes("select * from text where id =".$_GET['id']."") ;
    echo $sql ;
    $result = mysql_query($sql) ;if($row = mysql_fetch_array($result)){
        
    ?>
    <form action="index.php" method="post">
    <label>id</label><input type="text" name="id" readonly="" value="<?php echo $row['id'] ;?>"/><br />
    <textarea name="huitie" rows="10" cols="50"></textarea>
    <input type="submit" name="submit" value="确定"/>
    </form>
    <?php
        }    
    ?>tribune.php:
    <?php
    session_start();
    include('conn.php');
     if(isset($_POST['button2']))
      {
     header('location: ./tribune.php');
      }
           
    if(isset($_POST['submit'])){
             $sql = "insert into text(title,content,paotdate) values   ('".$_POST['title']."','".$_POST['content']."',now())" ;//插入数据
                mysql_query($sql) ;
               header('location: ./index.php');
    }
    ?>

    <! DOCTYPE html PUBLIC"-//W3C//DTD XHTML1.0Transitional//EN""http: //www.w3.org/TR/xhtml1/DTD/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>
    <link href="mystyle.css" rel="stylesheet" type="text/css"/>
    </head>
    <body>
    <style type="text/css">
    .table1 {
    background-color: #CCC;
    }
    .table1 tr .td1 {
    background-color: #FFF;
    }
    </style>
    <table width="100%" border="0"   cellspacing="0"  class="table1">
      <tr>
        <td width="18%" height="400" class="td1" >&nbsp;</td>
        <td width="52%" valign="top"><form name="form1" method="post" action="">
           <?php
      echo "用户:".$_SESSION['username']."欢迎光临本网页!<br>";
         
     
    ?><p align="right">
    <a href="index.php" >主页</a>
    <a href="tribune.php" >发表</a>
    <a href="quit.php" >退出</a><br>
    </p><br>
       <label >请发表你的珍贵意见:</label><br>
    <form action="tribune.php" method="post">
    <label>标题</label><input type="text" name="title"/><br>
    <label>内容</label><textarea rows="10" cols="50" name="content"></textarea>
    <input type="submit" name="submit" value="提交"/>
    </form>
       </td>
        <td width="30%" class="td1">&nbsp;</td>
      </tr> </table></body>
    </html>updata.php:<?php
    include('conn.php') ;
    $sql = "select * from text where id =".$_GET['id']."" ;
    $result = mysql_query($sql) ;
    if($row = mysql_fetch_array($result)){
        
    ?>
    <form action="update_do.php" method="post"><label>标题</label><input type="text" name="title" value="<?php echo $row['title'] ;?>"/><br />
    <textarea name="content" rows="10" cols="50"><?php echo $row['content'] ;?></textarea>
    <input type="submit" name="submit" value="修改"/>
    </form>
    <?php
        }    
    ?>update.php:
    <?php
      session_start();
      $name=$_SESSION['username'];
      if(!$_SESSION['isLogin'])
      {
       header('location: ./record.php');
      }
      else
      {
      echo "用户:".$_SESSION['username']."你好,欢迎光临!<br>";
      }
    include('conn.php') ;
    $sql = stripslashes("select * from text where id =".$_GET['id']."" );
    $result = mysql_query($sql) ;
    if($row = mysql_fetch_array($result)){
        
    ?>
    <form action="update_do.php" method="post">
    <label>id</label><input type="text" name="id" readonly="" value="<?php echo $row['id'] ;?>"/><br />
    <label>标题</label><input type="text" name="title" value="<?php echo $row['title'] ;?>"/><br />
    <textarea name="content" rows="10" cols="50"><?php echo $row['content'] ;?></textarea>
    <input type="submit" name="submit" value="修改"/>
    </form>
    <?php
        }    
    ?>update_do.php:
    <?php
      session_start();
      $name=$_SESSION['username'];
      if(!$_SESSION['isLogin'])
      {
       header('location: ./record.php');
      }
    include('conn.php') ;
    $sql = "update text set title='".$_POST['title']."' , content='".$_POST['content']."' where id='".$_POST['id']."'" ;
    mysql_query($sql) ;
    mysql_close($conn) ;header("location: index.php") ;    
    ?>
    就这样了 求前辈帮忙看看有错误帮忙修改或者说一说,这个学得不怎么懂,蒙蒙浓浓的做的。。谢谢