一 修改http.conf配置文件如下
<IfModule dir_module> DirectoryIndex index.html index.htm index.php index.asp </IfModule> <IfModule mod_php5.c> AddType application/x-httpd-php .php .asp .net .jsp AddType application/x-httpd-php-source .phps </IfModule>
二 保存文件,重启Apache服务器
三 创建文件index.php和index_ok.php
代码如下:
index.php
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>隐藏PHP文件扩展名</title> <link rel="stylesheet" type="text/css" href="css/style.css"> </head> <script src="js/check.js"></script> <body> <table width="1014" height="706" border="0" align="center" cellpadding="0" cellspacing="0" background="images/form1.jpg"> <tr> <td width="133" height="228"> </td> <td width="750"> </td> <td width="113"> </td> </tr> <tr> <td> </td> <td align="center" valign="top"> <form name="form_reg" method="post" action="index_ok.asp" onSubmit="return chkreginfo(form_reg,'all')"> <table width="620" height="262" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="120" height="30"><div align="right">用户名:</div></td> <td colspan="2"> <input type="text" name="recuser" size="20" class="inputcss" onBlur="chkreginfo(form_reg,0)"> <font color="#FF0000">*</font> <div id="chknew_recuser" style="color:#FF0000"></div></td> </tr> <tr> <td height="30"><div align="right">详细联系地址:</div></td> <td height="30" colspan="2"> <input type="text" name="address" size="60" class="inputcss" onBlur="chkreginfo(form_reg,1)"> <font color="#FF0000">*</font> <div id="chknew_address" style="color:#FF0000"></div></td> </tr> <tr> <td height="30"><div align="right">邮政编码:</div></td> <td height="30" colspan="2"> <input type="text" name="postalcode" size="20" class="inputcss" onBlur="chkreginfo(form_reg,2)"><div id="chknew_postalcode" style="color:#FF0000"></div></td> </tr> <tr> <td height="30"><div align="right">QQ号码:</div></td> <td height="30" colspan="2"> <input type="text" name="qq" size="20" class="inputcss" onBlur="chkreginfo(form_reg,3)"> <font color="#FF0000">*</font> <div id="chknew_qq" style="color:#FF0000"></div></td> </tr> <tr> <td height="30"><div align="right">E-mail:</div></td> <td height="30" colspan="2"> <input type="text" name="email" size="20" class="inputcss" onBlur="chkreginfo(form_reg,4)"> <font color="#FF0000">*</font> <font color="#999999">请务必正确填写您的邮箱</font> <div id="chknew_email" style="color:#FF0000"></div></td> </tr> <tr> <td height="30" align="right">固定电话:</td> <td height="30" colspan="2"> <input type="text" name="gtel" size="20" class="inputcss" onBlur="chkreginfo(form_reg,6)"> <font color="#FF0000">*</font> <font color="#999999"><div id="chknew_gtel" style="color:#FF0000"></div></font></td> </tr> <tr> <td height="30"><div align="right">移动电话:</div></td> <td height="30" colspan="2"> <input type="text" name="mtel" size="20" class="inputcss" onBlur="chkreginfo(form_reg,5)"> <font color="#FF0000">*</font> <div id="chknew_mtel" style="color:#FF0000"></div> <div align="right"></div></td> </tr> <tr> <td height="30"> </td> <td width="150" height="30"><input type="image" src="images/form (2).jpg"> </td> <td width="343"><img src="images/form.jpg" width="72" height="26" onClick="form_reg.reset()" style="cursor:hand"/></td> </tr> </table> </form></td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> </table> </body> </html>
index_ok.php
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>隐藏PHP扩展名</title> </head> <style type="text/css"> <!-- .style2 { color: #000000; font-size: 9pt; } .style3 { font-size: 9pt; font-weight: bold; } .style4 {font-size: 9pt} --> </style> <body> <table width="1014" height="706" border="0" align="center" cellpadding="0" cellspacing="0" background="images/form1.jpg"> <tr> <td width="175" height="236"> </td> <td width="501"> </td> <td width="338"> </td> </tr> <tr> <td height="175"> </td> <td valign="top"><table width="88%" border="0" cellspacing="-2" cellpadding="-2"> <tr> <td width="18%" height="22" align="center"><span class="style4">用 户 名:</span></td> <td width="82%" class="style4"> <?php echo $_POST[recuser]; ?></td> </tr> <tr> <td height="22" align="center"><span class="style4">地 址:</span></td> <td height="28" class="style4"> <?php echo $_POST[address];?></td> </tr> <tr> <td height="22" align="center"><span class="style4">邮编:</span></td> <td height="28" class="style4"> <?php echo $_POST[postalcode];?></td> </tr> <tr> <td height="22" align="center"><span class="style4">QQ:</span></td> <td class="style4"> <?php echo $_POST[qq];?></td> </tr> <tr> <td height="22" align="center" style="padding-left:10px"><span class="style4">Email:</span></td> <td class="style4"> <?php echo $_POST[email];?></td> </tr> <tr> <td height="22" align="center" class="style4" style="padding-left:10px">手机:</td> <td class="style4"><?php echo $_POST[mtel];?></td> </tr> <tr> <td height="22" align="center" class="style4" style="padding-left:10px">电话:</td> <td class="style4"><?php echo $_POST[gtel];?><strong></strong></td> </tr> </table></td> <td> </td> </tr> <tr> <td> </td> <td align="center" valign="top"> </td> <td> </td> </tr> </table> </body> </html>
四 代码完成后,将上面两个文件的后缀名修改为asp
五 运行结果
第一步:进入网站首页
http://localhost/test/21/13/index.asp
第二步:填写数据,提交数据