confirm.php<html>
<head>
<title>验证页面</title>
<body>
     <h2 align="center">用户注册确认页面</h2>
        <form name="registration" method="post" action="output.php" enctype="multipart/form-data">
           <table width="300" border="1" align="center" cellpadding="5" cellspacing="0" bgcolor="#EEEEFF">
                    <tr> 
                    <td width="47%" align="right"> <B>姓名</B> </td>
                    <td > 
<!--验证姓名的输入值.-->
          <?php
                    if(empty($name))
                    {
                    die("请认真填写用户名!");                    }
          //--- 验证姓名输入值的长度是否在5-20之间.                    elseif ( (strlen($name) < 5) || (strlen($name) > 20))
                    {
                    die("只能输入6-20位字母、数字、下划线的组合!");
                    }
                    else
                    {
          //--- 打印输入的姓名.
                     echo $name;
                    }
          ?>
                    </td>
                    </tr>
                    <tr> 
                    <td width="47%" height="57" align="right"><B>地址</B></td>
                    <td height="57"> 
     <!--验证地址输入的值.-->
          <?php
                    if(empty($address))
                    {
                    die("请填写您的地址!");                    }
                    elseif ( (strlen($address) < 5) || (strlen($address) > 100))
                    {
                    die("只能输入6-100位字母、数字、下划线的组合!");
                    }
                    else
                    {
                    echo $address;
                    }
          ?>
      <!--验证E-MAIL输入的值.-->
                    </td>
                    </tr>
                    <tr> 
                    <td width="47%" align="right"> <B>电子信箱</B> </td>
                    <td height="2"> 
          <?php
                    if(empty($email))
                    {
                    die("请填写您的e-mail地址!");                    }
                    elseif ( (strlen($email) < 5) || (strlen($email) > 20))
                    {
                    die("无效电子邮件,只能输入6-20位字母、数字、下划线的组合!");
                    }
                    elseif(!ereg("@",$email))
                    {
                    die("无效电子邮件, 没有发现@ 标志");
                    }
                    else
                    {
                    echo $email;
                    }
          ?>
                    </td>
                    </tr>
                    <tr> 
                    <td width="47%" align="right"> <B>密码</B></td>
                    <td height="2"> 
      <!--验证密码输入的值.-->
          <?php
                    if(empty($password) || empty($cpassword))
                    {
                    die("请填写您的密码");                    }
                    elseif ( ((strlen($password) < 5) || (strlen($password) > 15)))
                    {
                    die("密码长度只能输入6-15位");
                    }
                    elseif ( !(strlen($password) == strlen($cpassword)) )
                    {
                     die("您输入的密码与验证密码不相符,请认真填写!");
                    }
                    elseif( !($password === $cpassword))
                    {
                     die("您输入的密码与验证密码不相符,请认真填写!");
                    }
                    else
                    {
                    for ($i=0;$i<strlen($password);$i++)
                    {
                    echo "*";
                    }
                    }
          ?>
                    </td>
                    </tr>
                    <tr> 
                    <td width="47%" align="right"><B>出生日期</B></td>
                    <td height="2"> 
      <!--验证出生日期输入的值.-->
          <?php 
                    if (empty($birth_month) || empty($birth_day) || empty($birth_year) )
                    {
                    die("您输入的不正确或未填写.");
                     }
                    switch($birth_month)
                    {
                    case 1: print "1"; break;
                    case 2: print "2"; break;
                    case 3: print "3";break;
                    case 4: print "4";break;
                    case 5: print "5"; break;
                    case 6: print "6"; break;
                    case 7: print "7"; break;
                    case 8: print "8"; break;
                    case 9: print "9"; break;
                    case 10: print "10"; break;
                    case 11: print "11"; break;
                    case 12: print "12"; break;                    default: die("无效的月份!");
         }
                    if (($birth_day < 1) || ($birth_day > 31))
                    {
                    die("无效的输入,请检查!");
                    }
                    else 
                    {
                    echo $birth_day, "&nbsp;";
                    }
                    if (($birth_year < 1900) || ($birth_year >2100))
                    { 
                    die("无效的年份");
                    }
                    else
                    {
                    echo $birth_year;
                    }
          ?>
                    </td>
                    </tr>
                    <tr> 
                    <td width="47%" align="right"><B>性别</B></td>
                    <td height="2" width="26%"> 

解决方案 »

  1.   

    <!--验证性别输入的值.-->
              <?php
                        if (empty($gender))
                        {
                         die("请您选者其一!");
                        }
                        elseif (!(($gender=="Male") || ($gender=="Female")))
                        {
                        die("您输入的不正确,请从新输入!");
                        }
                        else
                        {
                        echo $gender;
                        }
              ?>
                        </td>
                        </tr>
                        <tr> 
                        <td width="47%" align="right"><B>类型</B></td>
                        <td height="2" colspan="2"> 
                        <table width="100%" border="0">
                        <tr> 
                        <td> 
         <!--验证类型输入的值.-->
         <?php
                        if ($fiction) 
                        {
                        echo "小说 <br>";
                        }
                        if ($horror) 
                        {
                        echo "恐怖 <br>";
                        }
                        if ($action) 
                        {
                        echo "动作 <br>";
                        }
                        if ($comedy) 
                        {
                        echo "喜剧 <br>";
                        }
              ?></td>
                        </tr>
                        </table>
                        </td>
                        </tr>
                        <tr> 
                        <td width="47%" height="47"align="right"><B>爱好</B></td>
                        <td colspan="2" height="47"> 
                        <p align="center"></p>
        <!--验证爱好输入的值.-->
                        <?php
                        for ($i=0; $i<count($hobbies);$i++)
                        {
                        echo $hobbies[$i] . "<br>";
                        }
              ?>
                        </td>
                        </tr>
    </table>
                        <tr> 
                        <td colspan="3"> 
                        <form Name=confirm action="output.php">
              <?php
                        echo "<input type=hidden name=\"name\" value=\"".$name."\" >\n";
                        echo "<input type=hidden name=\"address\" value=\"".$address."\" >\n";
                        echo "<input type=hidden name=\"email\" value=\"".$email."\" >\n";
                        echo "<input type=hidden name=\"birth_month\" value=\"".$birth_month."\" >\n";
                        echo "<input type=hidden name=\"birth_day\" value=\"".$birth_day."\" >\n";
                        echo "<input type=hidden name=\"birth_year\" value=\"".$birth_year."\" >\n";
                        echo "<input type=hidden name=\"interests\" value=\"".$interests."\" >\n";
                        for ($i=0;$i<count($hobbies);$i++)
                        {
                        echo "<input type=hidden name=\"hobbies[]\" value=\"".$hobbies[$i]."\" >\n";
                        }
                        if ($fiction)  
                        {
                        echo "<input type=hidden name=\"fiction\" value=\"".$fiction."\" >\n";
                        }
                        if ($action)   
                        {
                        echo "<input type=hidden name=\"action\" value=\"".$action."\" >\n";
                        }
                        if ($horror)
                        {
                        echo "<input type=hidden name=\"horror\" value=\"".$horror."\" >\n";
                        }
                        if ($comedy)   
                        {
                        echo "<input type=hidden name=\"comedy\" value=\"".$comedy."\" >\n";
                        }
              ?>
                        <center>
                          <input type="submit" name="Submit" value="Confirm >>">
                        </center>
                       </form>
                      </td>
                    </tr>
                </form>
           </body>
    </html>
      

  2.   

    为什么有那么多人不知道用$_POST,$_GET呢??
      

  3.   

    代码里面很多无谓的地方
      switch($birth_month)
                        {
                        case 1: print "1"; break;
                        case 2: print "2"; break;
                        case 3: print "3";break;
                        case 4: print "4";break;
                        case 5: print "5"; break;
                        case 6: print "6"; break;
                        case 7: print "7"; break;
                        case 8: print "8"; break;
                        case 9: print "9"; break;
                        case 10: print "10"; break;
                        case 11: print "11"; break;
                        case 12: print "12"; break;                    default: die("无效的月份!");
             }例如这里
      

  4.   

    在学校里 图书馆的书 一般都很旧,
    php方面 我看了我门那的书店 ,感觉很少,不知道是怎么回事