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

报告相同问题?

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化