用PHP制作的意见反馈表

  •   2009-08-01/08:15
  • 这是一个用PHP制作的意见反馈表,稍加修改也可用于网上发信程序,主要是让访问者填写表单,用PHP处理后发送到管理员信箱,并向访问者信箱发送一个证实信件。

    about.php
    -------------------------
    <html>
    <head>
    <title>意见反馈表</title>
    </head>
    <body>
    <?php

    $adminmail="admin@acme.oso.com.cn";        #管理员信箱
    $pagename="Acme";                        #主页名称
    $pageline="http://acme.oso.com.cn";    #主页地址

    #管理员信件内容
    if (($formno1!="") and ($formno4!="") and ($formno11!="")) {

    $Email=$formno4;      #来访者E-mail
    $sender=$formno1;     #送信人
    $nowtime=date("Y年m月d日H时i分");


      $tmpfilename = tempnam("./tmp", "dm");
      $fp = fopen($tmpfilename, "w");

      fwrite($fp, "From: ".$Email."n");
      fwrite($fp, "Subject: ".$sender."  <".$pagename."-意见反馈表>nn");
      fwrite($fp, "送信人:".$sender."n发信IP:".$REMOTE_ADDR."n发信时间:".$nowtime."nn");
      fwrite($fp, "反馈表详细内容:n------------------------------------------------------n");
      fwrite($fp, "姓名:".$formno1."n性别:".$formno2."n年龄:".$formno3."nE-mail:".$formno4."n工作单位:".$formno5."n联系地址:".$formno6."n邮编:".$formno7."n电话:".$formno8."n传真:".$formno9."n网址:".$formno10."n意见建议:".$formno11."n------------------------------------------------------n");
      fclose($fp);

      $execstr="cat ".$tmpfilename." | /usr/sbin/sendmail ".$adminmail;
      exec($execstr);

      $execstr="echo $sender  $nowtime  $REMOTE_ADDR $REMOTE_HOST >> mail.log";
      exec($execstr);

    #来客信件内容;
      $tmpfilename1 = tempnam("./tmp", "dm");
      $fp = fopen($tmpfilename1, "w");

      fwrite($fp, "From: ".$adminmail."n");
      fwrite($fp, "Subject: 你在[".$pagename."]填写的<意见反馈表>nn");
      fwrite($fp, "****此信为自动回复信件,请勿回复。给你带来不便,我们深表歉意。****nn------------------------------------------------------n非常感谢你在[".$pagename."]填写意见反馈表!n以下是您在".$nowtime."填写的详细内容,请确认:n------------------------------------------------------n");
      fwrite($fp, "姓名:".$formno1."n性别:".$formno2."n年龄:".$formno3."nE-mail:".$formno4."n工作单位:".$formno5."n联系地址:".$formno6."n邮编:".$formno7."n电话:".$formno8."n传真:".$formno9."n网址:".$formno10."n意见建议:".$formno11."n------------------------------------------------------n".$pagename.":".$pageline."nE-mail:".$adminmail);
      fclose($fp);

    $execstr="cat ".$tmpfilename1." | /usr/sbin/sendmail ".$Email;
      exec($execstr);

    #确认页开始;
    echo "
    <style type=text/css><STYLE>
    A {FONT-SIZE: 9pt}
    A:link {COLOR: #006666; }
    A:visited {COLOR: #006666;}
    A:hover {COLOR: #ff0000; TEXT-DECORATION: underline}
    TD {FONT-SIZE: 9pt}
    INPUT {FONT-SIZE: 9pt}
    </style>
    <br><p align=center><font size=4><b>*** 非常感谢你在<a href=$pageline>$pagename</a>填写意见反馈表! ***</b></font></p>以下是您填写的详细内容:<hr><br>
    <b>姓名:</b>$formno1<br>
    <b>性别:</b>$formno2<br>
    <b>年龄:</b>$formno3<br>
    <b>E-mail:</b>$formno4<br>
    <b>工作单位:</b>$formno5<br>
    <b>联系地址:</b>$formno6<br>
    <b>邮编:</b>$formno7<br>
    <b>电话:</b>$formno8<br>
    <b>传真:</b>$formno9<br>
    <b>网址:</b>$formno10<br>
    <b>意见建议:</b>$formno11<br><br>
    <font color=#993333>谢谢您!!!</font>
    <hr><input TYPE=button VALUE=返回上一页 OnClick=history.go(-1);return true;>
    <p align=center><font size=3>$pagename</font>:<a href=$pageline>$pageline</a></p></font><p>
    ";
    #确认页结束;

    } else {
      ?>
    <script language=javascript>
    function save(){
    if(f1.formno1.value!="" && f1.formno2.value!="" && f1.formno3.value!="" && f1.formno4.value!="" && f1.formno11.value!=""){
        f1.submit();
        }
        else{
        alert("带*为必填项,请全部填写后再次提交。nn 谢谢合作!");
        }
    }
    </script>
    <p align="center"><font size="5" color="#009999">意&nbsp;见&nbsp;反&nbsp;馈&nbsp;表</font></p><br>
                  <table width="90%" border="0" align="center" cellspacing="1" cellpadding="5" bgcolor="#F2F2F2">
            <tr>  
              <td>  
                 <form action=<? echo($GLOBALS["PHP_SELF"]); ?> method=post name=f1>
                  <table width="100%" border="0">
                    <tr>  
                      <td width="32%"> <font size="3">您的姓名:</font> <font size="3">  
                        <font color="#CC0000"> </font></font></td>
                      <td width="68%"> <font size="3">  
                        <input type="text" name="formno1" size="8">
                        <font color="#CC0000"> *</font></font></td>
                    </tr>
                    <tr>  
                      <td width="32%"> <font size="3">您的性别:</font></td>
                      <td width="68%"><font size="3">  
                        <select name="formno2">
                          <option value="男">男</option>
                          <option value="女">女</option>
                        </select>
                        <font color="#CC0000"> *</font></font></td>
                    </tr>
                    <tr>  
                      <td width="32%"><font size="3">您的年龄:</font> </td>
                      <td width="68%"><font size="3">  
                        <input type="text" name="formno3" size="3" maxlength="3">
                        <font color="#CC0000"> *</font></font></td>
                    </tr>
                    <tr>  
                      <td width="32%"> <font size="3">您的E-mail:</font></td>
                      <td width="68%"><font size="3">  
                        <input type="text" name="formno4" maxlength="40">
                        <font color="#CC0000"> *</font></font></td>
                    </tr>
                    <tr>  
                      <td width="32%"> <font size="3">您的工作单位:</font></td>
                      <td width="68%"><font size="3">  
                        <input type="text" name="formno5" maxlength="100">
                        </font></td>
                    </tr>
                    <tr>  
                      <td width="32%"><font size="3">您的联系地址:</font></td>
                      <td width="68%"><font size="3">  
                        <input type="text" name="formno6" maxlength="100">
                        </font></td>
                    </tr>
                    <tr>  
                      <td width="32%"><font size="3">您的邮政编码:</font></td>
                      <td width="68%">  
                        <input type="text" name="formno7" maxlength="10">
                      </td>
                    </tr>
                    <tr>  
                      <td width="32%"><font size="3">您的电话:</font></td>
                      <td width="68%">  
                        <input type="text" name="formno8" maxlength="20">
                      </td>
                    </tr>
                    <tr>  
                      <td width="32%"><font size="3">您的传真:</font></td>
                      <td width="68%">  
                        <input type="text" name="formno9" maxlength="20">
                      </td>
                    </tr>
                    <tr>  
                      <td width="32%"><font size="3">您的网址:</font></td>
                      <td width="68%">  
                        <input type="text" name="formno10" maxlength="100">
                      </td>
                    </tr>
                    <tr>  
                      <td width="32%" valign="top"><font size="3">意见或要求:</font></td>
                      <td width="68%">  
                        <textarea name="formno11" cols="30" rows="5"></textarea>
                        <font color="#CC0000">*</font></td>
                    </tr>
                    <tr>  
                      <td width="32%">&nbsp;</td>
                      <td width="68%">  
                    <input type=button value=" 发送 " onClick="javascript:save();" name="button">


                        <input type="reset" name="clear" value="清除">
                      </td>
                    </tr>
                    <tr>  
                      <td colspan="2">  
                        <p><br>
                          注:标 <font color="#CC0000">* </font>项目为必填项。</p>
                        </td>
                    </tr>
                  </table>
                </form>
              </td>
            </tr>
          </table>
      <?
    }
    ?>
    </body>
    </html>


    【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】    

    评论 {{userinfo.comments}}

    {{money}}

    {{question.question}}

    A {{question.A}}
    B {{question.B}}
    C {{question.C}}
    D {{question.D}}
    提交

    驱动号 更多