1

我有一个表格,我正在通过验证码进行验证。我有一个 if 语句。如果用户输入错误的验证码,它会告诉它返回。否则页面应重定向到以下内容

  http://tre.emv3.com/D2UTF8?emv_tag=876020001C384269&emv_ref=EdX7CqkdLe_d8SA9MOPQNCffL0p6Hq3D-jmueKEyWsbQKbo&FIRSTNAME_FIELD=XXXXXXXXX&LASTNAME_FIELD=XXXXXXXXX&DATEOFBIRTH_FIELD=XXXXXXXXX&EMAIL_FIELD=XXXXXXXXX&EMVCELLPHONE_FIELD=XXXXXXXXX&STORE_NAME_FIELD=XXXXXXXXX&

其中每个 XXXXXXXX 都应替换为表单中的变量。当我尝试下面的代码时,变量不会被替换。感谢您的帮助。

      <?php session_start(); ?>
      <?php 
      ob_start();
          date_default_timezone_set("Europe/London");
          include_once $_SERVER['DOCUMENT_ROOT'] . '/maininc/securimage/securimage.php';

          $securimage = new Securimage();
          if ($securimage->check($_POST['captcha_code']) == false) {
            // the code was incorrect
            // you should handle the error so that the form processor doesn't continue

            // or you can use the following code if there is no validation or you do not know how
            echo "THIS IS WRONG.<br /><br />";
            echo "Please go <a href='javascript:history.go(-1)'>back</a> and try again.";
            exit;
          }else{
           $FIRSTNAME_FIELD = $_POST['FIRSTNAME_FIELD'];
           $LASTNAME_FIELD = $_POST['LASTNAME_FIELD'];
           $DATEOFBIRTH_FIELD = $_POST['DATEOFBIRTH_FIELD'];
           $EMAIL_FIELD = $_POST['EMAIL_FIELD'];
           $EMVCELLPHONE_FIELD = $_POST['EMVCELLPHONE_FIELD'];
           $STORE_NAME_FIELD = $_POST['STORE_NAME_FIELD'];
           header('location: http://tre.emv3.com/D2UTF8?emv_tag=876020001C384269&emv_ref=EdX7CqkdLe_d8SA9MOPQNCffL0p6Hq3D-jmueKEyWsbQKbo&FIRSTNAME_FIELD=echo$FIRSTNAME_FIELD;&LASTNAME_FIELD=echo$LASTNAME_FIELD;&DATEOFBIRTH_FIELD=echo$DATEOFBIRTH_FIELD;&EMAIL_FIELD=echo$EMAIL_FIELD;&EMVCELLPHONE_FIELD=echo$EMVCELLPHONE_FIELD;&STORE_NAME_FIELD=echo$STORE_NAME_FIELD;&');
          }
      ob_end_flush();
      exit;
      ?>
4

2 回答 2

0

header您在函数中的字符串由'. 这不会转换变量。更改周围环境'"删除 echo 命令。

       header("location: http://tre.emv3.com/D2UTF8?emv_tag=876020001C384269&emv_ref=EdX7CqkdLe_d8SA9MOPQNCffL0p6Hq3D-jmueKEyWsbQKbo&FIRSTNAME_FIELD=$FIRSTNAME_FIELD&LASTNAME_FIELD=$LASTNAME_FIELD&DATEOFBIRTH_FIELD=$DATEOFBIRTH_FIELD&EMAIL_FIELD=$EMAIL_FIELD&EMVCELLPHONE_FIELD=$EMVCELLPHONE_FIELD&STORE_NAME_FIELD=$STORE_NAME_FIELD");
于 2012-12-04T12:31:41.350 回答
0

摆脱链接中的回声并使用 header(" .. ") 而不是 '

在这里阅读为什么http://php.net/manual/en/language.operators.string.php

于 2012-12-04T12:35:03.103 回答