donjao6770 2015-04-11 10:03
浏览 18
已采纳

如何用php构建服务器端脚本

I am trying to start an online service. Users fill out a form submit it then go to another page. On the 2nd page they choose a service. From that page they go to a 3rd page. I would like to do this in 3 pages as to encourage users to finish the sequence (they are already invested time-wise by 2nd page).

How could I better send data from page 1 to page 3? So far I was just going to send data from page 1 to a server side php script, send that data to page 2 then repeat the process until page 3. Is there a more proper way to accomplish this?

my code for the form submit is

<?php
$varRedirect = "order.php";

if(isset($_POST["submit"]) )
{

  $var1 = $_POST["element_1"];
    $var2 = $_POST["element_1"];
      $var3 = $_POST["element_1"];
        $var4 = $_POST["element_1"];
          $var5 = $_POST["element_1"];
            $var6 = $_POST["element_1"];
              $var7 = $_POST["element_1"];
                $var8 = $_POST["element_1"];
                  $var9 = $_POST["element_1"];
}

/* begin switch logic */


redirect($varRedirect."?var1=".$var1."&var2=".$var2."&var3=".$var3."&var4=".$var4."&var5=".$var5."&var6=".$var6."&var7=".$var7."&var8=".$var8."&var9=".$var9);
/* functions */
function redirect($url, $statusCode = 303)
{
header('location: ' .$url, true, $statusCode);
die();
}
?>
  • 写回答

3条回答 默认 最新

  • dongxie7683 2015-04-11 14:43
    关注

    if you prefer redirect, you can simplify the process by using http_build_query

    $params = $_POST;
    unset($params['submit']); // exclude 'submit' if you don't need it
    $query = http_build_query($parms); 
    redirect($varRedirect."?$query);
    

    not checked well, but you can see the idea.

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

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大