0

我将网站从其他托管服务器移至其他托管服务器,但联系表格不起作用。当前版本的 php 是 5.2,之前版本更旧。我在论坛上看到,为了让旧的 php 代码工作,我应该打开我所做的全局变量(我知道它不安全,我将完全替换该代码,但现在我必须让它工作)。在我打开全局变量之前没有任何工作,现在如果缺少某些字段,我会收到消息,但仅此而已。有什么建议如何使此联系​​表格起作用吗?任何答案将不胜感激。

<?
$contact = 'contact';

require('inc_meta.php');

if($form)
{
$error = Array();
if(!trim($c_name)){ $error[sizeof($error)] = "Name"; }
if(!trim($email)){ $error[sizeof($error)] = "E-mail Address"; }
else {
if(!eregi("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}$",$email)){ $error[sizeof($error)] = "'" . $email . "' is not avalid E-mail Address."; }
}
}
$filePath = getenv("SCRIPT_NAME");
if($_SERVER['HTTP_REFERER'] == 'http://'.$_SERVER['SERVER_NAME'].''.$filePath.'')
{
if($form && !$error)
{
$contents = "Name: $c_name\r
Address:\r
$c_address\r
$c_city, $c_state $c_zip\n
Phone: $c_phone\r
Fax: $c_fax\r
Email: $email\n
Comments or Questions:\r
$c_comments";

mail("$EMAILADMIN","email from $c_name","$contents","From: $c_name<$email>");

          $status = "Thank You, <b>$c_name</b><br><br>";
          $status .= "Your e-mail message has been sent. We will contact you shortly about your inquiry. ";
          $status .= "If you need more assistance or have questions, please call us at <b>1234567</b><br><br>";
          $status .= "Thank You,<br><b>Owner</b><br>";

}}
?>
<table width="860" border="0" cellspacing="0" cellpadding="0">
  <tr valign="top"> 
    <td width="325"> 
      <? include('inc_sideBar.php'); ?>
    </td>
    <td width="535">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td> 
            <? include('inc_header.php'); ?>
          </td>
        </tr>
        <tr> 
          <td> 
            <table width="100%" border="0" cellspacing="0" cellpadding="6">
              <tr> 
                <td align="center" valign="top"> 
                  <? if(!$status){ ?>
                  <br>
                  <table width="95%" border="0" cellspacing="0" cellpadding="0">
                    <tr> 
                      <form name="form" method="post" action="<? echo $PHP_SELF; ?>">
                        <td> 
                          <? if(sizeof($error)){ ?>
                          <font color="#FADE82"><b> The following fields are still 
                          required:<br>
                          <?
         for($i = 0; $i < sizeof($error); $i++) {
         echo "&nbsp;*", "&nbsp;", $error[$i];
         }
         ?>
                          </b></font><br>
                          <br>
                          <? } ?>
                          <table width="100%" border="0" cellspacing="1" cellpadding="1">
                            <tr> 
                              <td width="54%" valign="top"><font color="#FFF9DD">Name</font><font color="#CC0000"> 
                                <font color="#FADE82"></font></font><b><font color="#CC0000"><font color="#FADE82">*</font><br>
                                <input type="text" name="c_name" value="<? echo $c_name; ?>" size="23">
                                </font></b></td>
                              <td width="46%" valign="top"><font color="#FFF9DD">State</font><b><br>
                                </b> 
                                <select name="c_state">
                                  <option> 
                                  <? echo $c_state; ?>
                                  </option>
                                  <option value="AL">Alabama</option>
                                  <option value="AK">Alaska</option>
                                  <option value="AZ">Arizona</option>
                                  <option value="AR">Arkansas</option>
                                  <option value="CA">California</option>
                                  <option value="CO">Colorado</option>
                                  <option value="CT">Connecticut</option>
                                  <option value="DE">Delaware</option>
                                  <option value="FL">Florida</option>
                                  <option value="GA">Georgia</option>
                                  <option value="HI">Hawaii</option>
                                  <option value="ID">Idaho</option>
                                  <option value="IL">Illinois</option>
                                  <option value="IN">Indiana</option>
                                  <option value="IA">Iowa</option>
                                  <option value="KS">Kansas</option>
                                  <option value="KY">Kentucky</option>
                                  <option value="LA">Louisiana</option>
                                  <option value="ME">Maine</option>
                                  <option value="MD">Maryland</option>
                                  <option value="MA">Massachusetts</option>
                                  <option value="MI">Michigan</option>
                                  <option value="MN">Minnesota</option>
                                  <option value="MS">Mississippi</option>
                                  <option value="MO">Missouri</option>
                                  <option value="MT">Montana</option>
                                  <option value="NE">Nebraska</option>
                                  <option value="NV">Nevada</option>
                                  <option value="NH">New Hampshire</option>
                                  <option value="NJ">New Jersey</option>
                                  <option value="NM">New Mexico</option>
                                  <option value="NY">New York</option>
                                  <option value="NC">North Carolina</option>
                                  <option value="ND">North Dakota</option>
                                  <option value="OH">Ohio</option>
                                  <option value="OK">Oklahoma</option>
                                  <option value="OR">Oregon</option>
                                  <option value="PA">Pennsylvania</option>
                                  <option value="RI">Rhode Island</option>
                                  <option value="SC">South Carolina</option>
                                  <option value="SD">South Dakota</option>
                                  <option value="TN">Tennessee</option>
                                  <option value="TX">Texas</option>
                                  <option value="UT">Utah</option>
                                  <option value="VT">Vermont</option>
                                  <option value="VA">Virginia</option>
                                  <option value="WA">Washington</option>
                                  <option value="DC">Washington, D.C.</option>
                                  <option value="WV">West Virginia</option>
                                  <option value="WI">Wisconsin</option>
                                  <option value="WY">Wyoming</option>
                                </select>
                              </td>
                            </tr>
                            <tr> 
                              <td valign="top" width="54%"><font color="#FFF9DD">E-mail</font><font color="#CC0000"> 
                                <font color="#FADE82"></font></font><b><font color="#CC0000"><font color="#FADE82">*</font> 
                                <br>
                                <input type="text" name="email" value="<? echo $email; ?>" size="23">
                                </font></b></td>
                              <td valign="top" width="46%"><font color="#FFF9DD">Zip</font><b><br>
                                </b> 
                                <input type="text" name="c_zip" value="<? echo $c_zip; ?>" size="20">
                              </td>
                            </tr>
                            <tr> 
                              <td valign="top" width="54%"><font color="#FFF9DD">Address</font><b><br>
                                <input type="text" name="c_address" value="<? echo $c_address; ?>" size="23">
                                </b></td>
                              <td valign="top" width="46%"><font color="#FFF9DD">Phone</font><b><br>
                                </b> 
                                <input type="text" name="c_phone" value="<? echo $c_phone; ?>" size="20">
                              </td>
                            </tr>
                            <tr> 
                              <td valign="top" width="54%"><font color="#FFF9DD">City</font><b><br>
                                <input type="text" name="c_city" value="<? echo $c_city; ?>" size="23">
                                </b></td>
                              <td valign="top" width="46%"><font color="#FFF9DD">Fax</font><b><br>
                                </b> 
                                <input type="text" name="c_fax" value="<? echo $c_fax; ?>" size="20">
                              </td>
                            </tr>
                            <tr> 
                              <td valign="top" width="54%">&nbsp;</td>
                              <td valign="top" width="46%">&nbsp; </td>
                            </tr>
                            <tr> 
                              <td valign="top" colspan="2"> <font color="#FFF9DD">Comments 
                                or Questions?:</font><br>
                                <textarea name="c_comments" wrap="VIRTUAL" cols="30" rows="5"><? echo $c_comments; ?></textarea>
                                <br>
                                <br>
                              </td>
                            </tr>
                            <tr> 
                              <td valign="top" colspan="2"> 
                                <input type="image" border="0" name="imageField" src="images/submit.gif" class="select">
                              </td>
                            </tr>
                          </table>
                          <input type="hidden" name="form" value="one">
                        </td>
                      </form>
                    </tr>
                  </table>
                  <? }else{ ?>
                  <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr> 
                      <td> <br>
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                          <tr> 
                            <td> 
                              <font color="#FFF9DD"><? echo $status; ?></font>
                            </td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table>
                  <? } ?>
                </td>
              </tr>
            </table>
            <br>
            <? include('footer_info.php'); ?>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<? require('inc_footer.php'); ?>
4

1 回答 1

0

您应该使用 $_POST 数组访问表单数据。
阅读 php 文档此页面中的警告:http ://www.php.net/manual/en/language.variables.predefined.php

于 2013-04-10T16:30:08.997 回答