dtfpznrbn503027700 2013-09-19 14:33
浏览 37
已采纳

为什么我的表单没有提交和重定向?

I am trying to migrate our site to a new host that uses PHP5. Previously we were on PHP4.

I have a form that is not submitting and redirecting to the thankyou page after a user fills out a survey which worked previously on php4. I'm sure it's probably something obvious that I'm missing but I can't see why it doesn't work.

When I click submit, the survey page reloads, the URL gets ?submit=t added to the end and the email is not sent to me.

The code from our survey.php is shown below with my email address and most of the HTML form feilds removed. Can somebody point me in the right direction?

Thanks!

  <?
$APP_ROOT = "../";
$FILE = __FILE__;
$TITLE="Service Survey";

if(!isset($submit)) {

    include($APP_ROOT."include/header.php");
    include($APP_ROOT."include/nava.php");
?>
<div class="bodymargin">
     <img src="<?=$WEB_ROOT;?>images/titles/<?=$SECTION."_".$FILE;?>.gif" width="400" height="36"><br>
    <br>
     <form method="POST" action="<?=$FILE;?>.php?submit=t">

<?
    if(isset($error)) {
        while(list($key, $value) = each($HTTP_GET_VARS)) {  
            $$key = stripslashes($value);
        }
        print("<p class=\"alert\">". urldecode($error) . "</p>
"); 
    }
?> 
<input type="text" name="name" value="<?=$name;?>">
</form>

<?  
    include($APP_ROOT."include/navb.php");
    include($APP_ROOT."include/footer.php");
} else {
    include_once($APP_ROOT . "functions/index.php");
    include_once($APP_ROOT . "functions/form_validation.php");
    $CONTINUE = TRUE;


    $valid = new Validation($HTTP_POST_VARS);
    if($CONTINUE = $valid->success) {
        $to = "myemailaddress";
        $subject = "Service Survey";
        $from_email = $to;
        $from_name = "mysite.com";
        $headers = "From: $from_name<$from_email>
"; 
        $headers .= "Reply-To: <$email>
";
        $headers .= "Return-Path: <$from_email>
"; 

        $body = "The following information was just posted 
";

        unset($HTTP_POST_VARS['required_fields']);
        reset($HTTP_POST_VARS);
        while(list($key, $value) = each($HTTP_POST_VARS)) {
            if(!empty($value)) {
                $body .= proper_form($key) . ":  " . stripslashes($value) ."
";
            }   
        }
        $body .= "
This is an automated message, please do not respond.";
        mail($to,$subject,$body,$headers);
        $URL = $WEB_ROOT . "/customer/thanks.php?form=" . $FILE;
        server_redirector($URL);
    } else {
        while(list($key, $value) = each($HTTP_POST_VARS)) {
            $rebound .= "&$key=" . urlencode(stripslashes($value));
        }
        $URL = $WEB_ROOT . "customer/survey.php?error=". urlencode(nl2br($valid->errors)) . $rebound;
        server_redirector($URL);
        die();
    }
}
?>
  • 写回答

3条回答 默认 最新

  • dongshanya2008 2013-09-19 14:37
    关注

    regsiter_globals is not active in newer PHP versions. So instead of using if(!isset($submit)) you have to use if(!isset($_GET['submit'])). And for posted values, you use $_POST['parameter'].

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效