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 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)