我使用XAMPP安装包,还需要再怎样设置吗还是这个软件包已经什么设置好了,就想做个注册页面,已建好数据库了,但就是信息写不进去数据库会有哪些原因呢

解决方案 »

  1.   

    数据库连接文件conn.php
    <?php  
      $connect=mysql_connect('localhost','root','123456');//连接MySQL 
       
        if(!$connect)
         {   
      die('Could not connect: ' . mysql_error());
         }
        else
         {
           echo "连接成功";    //连接失败,显示"连接失败";
         }
    ?>以下是接受注册页面并读出的代码,但是在注册页面上按提交按钮(我让链接到此页面)后并没有转到此页面,数据库中也没有增加这一纪录,觉得是不是数据库没有连接上?但为什么没有显示连接失败的话语,求助求助!!!!
    <?php  include("conn.php");  ?>
    <?php
        $select=mysql_select_db("readDB",$connect)//readDB为数据库
    if($select)
        {
          echo "选择数据库成功!";
        }
        else
        {
           echo "选择数据库失败!";
        }
      $textfield = $_POST['textfield'];  //姓名
      $textfield2 = $_POST['textfield2'];  // 密码
      $textfield3=$_POST['textfield3'];  //邮箱
      $sql="insert into regiTable(userID,username,password,mail)values('',$textfield,$textfield2,$textfield3)"; //插入数据库表regiTable 
        $query = mysql_query($sql, $connect);
          //根据记录写入成功与否,输出相应的返回信息.
          if($query)
          {
             echo "写入成功";
          }
          else
          {
             echo "写入失败";
              exit;
          }
      
         $query = "select * from regiTable";
         $result = mysql_db_query("readDB", $query); 
     
         while ($r = mysql_fetch_array($result)) 
     {
           echo "<tr>
           <td align=center>您好<?php echo $r["username"];?> </td>
       <td align=center>您的邮箱是<?php echo $r["mail"];?> </td>
     }
        
     
      mysql_close();//关闭MySQL连接  
      echo "成功录入数据"; 
        ?>
      

  2.   

    mysql_connect(.....) or die(mysql_error());
      

  3.   

    没有任何反应啊,注册页面按提交按钮后 没有出现任何话,仍是这注册原页面不动。但是若是数据库接错误 它起码会输出“选择数据库失败!”  我用的是XAMPP安装包,它里面包含了所用的软件,我只是安装了,是不是还需什么设置呀。。求助
      

  4.   

    以前遇到过SQL语句少空格所以无效的问题,LZ
    insert into regiTable (userID, username, password, mail) values ('', '$textfield', '$textfield2', '$textfield3')
      

  5.   

    <html>
     <head>
      <title>制作会员样式</title>
     </head>
     <body bgcolor="#FFFFFF">
      <form action="注册信息录入数据库.php" method="post" enctype="text/plain">
      <table width="600" border="0" cellspacing="0" cellpadding="0" align="center">
       <tr>
        <td align="center">
        <center>
        <img src="会员加入.jpg">           <!--表格顶上图片-->
        </center>
        </td>
       </tr>
       <tr>
       <td align="center">&nbsp;</td>                    <!--空格-->
       </tr>   <tr>
        <td>
         <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr bgcolor="#009900">
            <td>
              <table width="100%" border="0" cellspacing="1" cellpadding="4">   
                <tr bgcolor="#009933">
                 <td colspan="2" align="center"><b>基本信息</b></td>    <!--第一行-->
                </tr>

                <tr>
                  <td bgcolor="#FFFFFF" width="20%" align="center">用户名</td>          
                  <td bgcolor="#FFFFFF">
                    <input type="text" name="textfield" size="20" maxlength="30">     <!--第二行-->
                  </td>
                </tr>            <tr>
                 <td bgcolor="#FFFFFF" align="center">密码</td>          
                 <td bgcolor="#FFFFFF">
                  <input type="password" name="textfield2" id="textfield2" size="8" maxlength="10">
                    英文字母/数字组合,3~8字,<b>密码确认</b>
                  <input type="password" name="textfield22" id="textfield22" size="8" maxlength="10">  <!--第三行-->
                 </td>
                </tr>            <tr>
                 <td bgcolor="#FFFFFF"  align="center">E-mail  </td>   
                 <td bgcolor="#FFFFFF">
                  <input type="text" name="textfield3" size="20" maxlength="50">     <!--第四行-->
                  (例)[email protected]  </td>
                </tr>
       </table>
     </td>
           </tr>
      </table>
     </td>
    </tr>

        <tr>
          <td align="right" height="20">&nbsp;</td>                    <!--空格-->
        </tr>
       
        <tr>
     <td align="center" height="20">
       <table width="22%" border="0" cellpadding="0" cellspacing="0" align="center">
        <tr>
     <td align="center">
    <input type="reset" name="button" id="button" value="重设" /> 
    &nbsp;&nbsp;
     <input type="submit" name="button" id="button" value="提交" />
     </td>
     <td align="right" height="20">&nbsp;</td>                    <!--空格-->
    </tr>
       </table>
      </td>
     </tr>
    </table>
      </form>
     </body>
    </html>   
    action="注册信息录入数据库.php"即链接到上面的代码
      

  6.   

    你的处理页面是以中文名命名的?  
    print_r($_POST); //在处理页面加上这句看能打印结果出来吗
      

  7.   


    点击提交后会进入下载的页面?嘿嘿,应该是你的apache配置文件没有配置好这个加了么
    LoadModule php5_module D:/php/php5apache2_2.dll
    AddType application/x-httpd-php .php
      

  8.   

    apache 不支持中文 url 的你把 注册信息录入数据库.php 换个英文名或用汉语拼音
      

  9.   

    嗯,中文命名的,就叫  注册信息录入数据库.php   要把这句print_r($_POST);直接放入这个上面代码中还是怎样我直接放入但也没反应,你说用不用写一个html页面 将 注册信息录入数据库.php  和print_r($_POST);这句话插入进去? 还是怎样?
      

  10.   

    $sql="insert into regiTable(userID,username,password,mail)values(default,'$textfield','$textfield2','$textfield3')"; //插入数据库表
      

  11.   


    我只在我的里面找到php/php5apache2_2.dll
    其他的不知道在哪,你说是要下载这些还是找到后怎么修改。
      

  12.   

    首先把你的文件名改为英文,比如check.php,然后在check.php中加上print_r($_POST); 看能输出结果吗。
      

  13.   

    另外将表单中的 enctype="text/plain" 删去
      

  14.   

    表单带有 enctype="text/plain" 属性时
    php 需用
     $s = file_get_contents('php://input');
    接收数据,并自行分析传入的数据
      

  15.   

    表单中还有两个name相同的<input> ,改成不一样的
      

  16.   


    去掉了 还是以前的样子啊  是不是配置有问题啊 XAMPP安装包 还需要什么修改配置吗
      

  17.   

    那你环境可能有问题了。随便建个test.php输出'hello world'试试。
    <?php  echo 'ehllo';?> //能不能输出
      

  18.   

    那么你在浏览器地址栏打入 http://localhost/conn.php
    会出现什么?
      

  19.   


    出现Parse error: syntax error, unexpected T_VARIABLE in D:\xampp\htdocs\conn.php on line 10
      

  20.   


    是放到htdocs目录下吧  结果出现了hello 
      

  21.   

    将放到htdocs目录下,
    <?php  
      $connect=mysql_connect('localhost','root','123456') or die("Problem connecting to DataBase");//连接MySQL 
    ?>结果出现
    Parse error: syntax error, unexpected T_VARIABLE in D:\xampp\htdocs\conn.php on line 2
      

  22.   

    你的xampp中apache和mysql都启动了吗
      

  23.   

    试试这个 test1.php
    <?php 
    if(mysql_connect('localhost','root','123456'))
        echo 'connect is ok';
    else
        echo 'fail';
    ?>另一个接收表单数据的页面增加一行
     print_r($_POST);
    其余的代码用 /* ... */ 屏蔽掉
    看看表单接收行不行
      

  24.   

    我重新写了个conn.php
    <?php
    $connect = mysql_connect("localhost","root","123456");
    if ($connect)
      {
       echo '连接成功!';
      }
      else{
      echo '连接失败!';
      
      }
    ?>结果出现 连接成功!能说明什么呢!!!!
      

  25.   

    我重新写了个conn.php
    <?php
    $connect = mysql_connect("localhost","root","123456");
    if ($connect)
      {
      echo '连接成功!';
      }
      else{
      echo '连接失败!';
       
      }
    ?>结果出现 连接成功!能说明什么呢!!!! 
     
      

  26.   

    应该启动了。。看xampp主面上显示这两都 running
      

  27.   


    还是老样子啊,是不是conn.php连接成功说明我的数据库是好的?是不是应该是我的接受页面有语法错误吧?
      

  28.   

    en 数据库是连接成功了。处理页面你打印一下$_POST看有值吗。
      

  29.   

    用print_r($_POST);
    其余的代码用 /* ... */ 屏蔽掉接受表单数据页面还是没反应。像以前一样。。
      

  30.   

    <html>
     <head>
      <title>制作会员样式</title>
     </head>
     <body bgcolor="#FFFFFF">
      <form action="log in DB.php" method="post" >
      <table width="600" border="0" cellspacing="0" cellpadding="0" align="center">
       <tr>
        <td align="center">
        <center>
        <img src="regi.jpg">           <!--表格顶上图片-->
        </center>
        </td>
       </tr>
       <tr>
       <td align="center">&nbsp;</td>                    <!--空格-->
       </tr>   <tr>
        <td>
         <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr bgcolor="#009900">
            <td>
              <table width="100%" border="0" cellspacing="1" cellpadding="4">   
                <tr bgcolor="#009933">
                 <td colspan="2" align="center"><b>基本信息</b></td>    <!--第一行-->
                </tr>

                <tr>
                  <td bgcolor="#FFFFFF" width="20%" align="center">用户名</td>          
                  <td bgcolor="#FFFFFF">
                    <input type="text" name="textfield" size="20" maxlength="30">     <!--第二行-->
                  </td>
                </tr>            <tr>
                 <td bgcolor="#FFFFFF" align="center">密码</td>          
                 <td bgcolor="#FFFFFF">
                  <input type="password" name="textfield2" id="textfield2" size="8" maxlength="10">
                    英文字母/数字组合,3~8字,<b>密码确认</b>
                  <input type="password" name="textfield22" id="textfield22" size="8" maxlength="10">  <!--第三行-->
                 </td>
                </tr>            <tr>
                 <td bgcolor="#FFFFFF"  align="center">E-mail  </td>   
                 <td bgcolor="#FFFFFF">
                  <input type="text" name="textfield3" size="20" maxlength="50">     <!--第四行-->
                  (例)[email protected]  </td>
                </tr>
       </table>
     </td>
           </tr>
      </table>
     </td>
    </tr>

        <tr>
          <td align="right" height="20">&nbsp;</td>                    <!--空格-->
        </tr>
       
        <tr>
     <td align="center" height="20">
       <table width="22%" border="0" cellpadding="0" cellspacing="0" align="center">
        <tr>
     <td align="center">
    <input type="reset" name="button" id="button" value="重设" /> 
    &nbsp;&nbsp;
     <input type="submit" name="button" id="button" value="提交" />
     </td>
     <td align="right" height="20">&nbsp;</td>                    <!--空格-->
    </tr>
       </table>
      </td>
     </tr>
    </table>
      </form>
     </body>
    </html>   
    接受表单数据log in DB.php<?php  include("conn.php");  ?>
    <?php
       
        $select=mysql_select_db("readDB",$connect)//readDB为数据库
    if($select)
        {
          echo "选择数据库成功!";
        }
        else
        {
           echo "选择数据库失败!";
        }
    //print_r($_POST);  $textfield = $_POST['textfield'];  //姓名
      $textfield2 = $_POST['textfield2'];  // 密码
      $textfield3=$_POST['textfield3'];  //邮箱 
        echo $textfield;
        echo $textfield2;
      $sql="insert into regiTable (userID, username, password, mail)values('', '$textfield', '$textfield2', '$textfield3')";             //插入数据库表regiTable    
        $query = mysql_query($sql, $connect);
          //根据记录写入成功与否,输出相应的返回信息.
          if($query)
          {
             echo "写入成功";
          }
          else
          {
             echo "写入失败";
              exit;
          }
      
         $query = "select * from regiTable";
         $result = mysql_db_query("readDB", $query); 
     
         while ($r = mysql_fetch_array($result)) 
     {
           echo "<tr>
           <td align=center>您好<?php echo $r["username"];?> </td>
       <td align=center>您的邮箱是<?php echo $r["mail"];?> </td>
     }
        
     
      mysql_close();//关闭MySQL连接  
      echo "成功录入数据"; 
        ?>
          嘿嘿,谢谢大家啦
      

  31.   

    文件名怎么能包含空格? 直接
    1        action="db.php" 
    2       接受表单数据文件 db.php 
      

  32.   

    <input type="reset" name="button" id="button" value="重设" /> 
    &nbsp;&nbsp;
    <input type="submit" name="button" id="button" value="提交" />
    改为:<input type="reset" name="reset"  value="重设" /> 
    &nbsp;&nbsp;
    <input type="submit" name="submit"  value="提交" />    //这样更规范,id可要可不要。
      

  33.   

    额...好神奇!一个简单的问题居然有这么多回复!
    不知道楼主问题解决了没有,调试的时候多用echo输出下,先把问题出在哪儿确定下来,剩下的就好办了!
      

  34.   

    我在我主机上测试了一下,文件名不管有没有空格都没问题 ,一切正常现在可以说,如果你还是print_r($_POST)没输出的话
    只能说明Apache或php.ini有问题。 可以先试试用get方法传递表单,然后print_r($_GET)
      

  35.   


    简单问题吗,其实我都觉得好高深那。。嘿嘿。。第一次接触好,多用echo。。
      

  36.   

     好吧,配置就这样了,你再Google一下吧 。 我对服务器配置一窍不通。还是等待高人吧
     最后别忘结贴给分啊。
      

  37.   

    把sql语句echo出来,放到命令行下去执行下,看成功不.
      

  38.   

    额...好神奇!一个简单的问题居然有这么多回复!
    不知道楼主问题解决了没有,调试的时候多用echo输出下,先把问题出在哪儿确定下来,剩下的就好办了!
      

  39.   

    mysql_select_db("readDB");
    $result = mysql_db_query($query,$connect);