duanmu3049 2015-05-28 16:32
浏览 29

PHP可以继续/编辑页面Post / RedirectGet Pattern PHP

I have a structural question for the Post Redirect Get pattern in PHP with a form process I am building. Basically, I have a PHP form at first where a user fills in fields.

Then upon pressing submit, the form posts to itself and server side validation happens testing if submitted like so:

if(isset($_POST['submitted'])){

// Firstname
if(!empty($_POST['firstname'])){
    $firstName = filter_var(trim($_POST['firstname']), FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES);
} else {
    $errors[] = "Please enter your first name";
}

}

If all of these tests pass for the form, I then do the PRG Pattern and redirect to an intermediary form like so:

if(empty($errors)){//proceed to process 

    //Dump your POST variables
    $_SESSION['POST'] = $_POST;

    // Redirect to Verification page
    header('Location: quote_verify.php', true, 303);
}

So far so good. The problem lies in the intermediary form. Every PRG pattern example I have seen just basically does the redirect to the "success" page which is simple. What I wish to do is after the user submits the form and there are no errrors... then the page changes and all the data the user entered is displayed back out and a couple of buttons are presented, "EDIT", and "SUBMIT QUOTE" So basically I need an intermediary page that shows what the user entered into the primary form and then if they want to edit the form by pressing the button, it will reload the original form and RETAIN the information in the form fields so it doesn't need to be entered again....if they press SUBMIT QUOTE, it basically generates then uses PHP SwiftMailer to construct and email object and emails the form and constructs a thank you email.

It is puzzling how to construct this in either a one page PRG pattern PHP form or the 3 page pattern I have so far. Thanks Overflow!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度