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条)

报告相同问题?

悬赏问题

  • ¥30 关于用python写支付宝扫码付异步通知收不到的问题
  • ¥50 vue组件中无法正确接收并处理axios请求
  • ¥15 隐藏系统界面pdf的打印、下载按钮
  • ¥15 MATLAB联合adams仿真卡死如何解决(代码模型无问题)
  • ¥15 基于pso参数优化的LightGBM分类模型
  • ¥15 安装Paddleocr时报错无法解决
  • ¥15 python中transformers可以正常下载,但是没有办法使用pipeline
  • ¥50 分布式追踪trace异常问题
  • ¥15 人在外地出差,速帮一点点
  • ¥15 如何使用canvas在图片上进行如下的标注,以下代码不起作用,如何修改