如何将单个表单重定向到2个单独的页面?谁能帮助我将相同的数据获取到2个单独的页面?
我尝试输入代码类型
<?php
if (isset($_POST['Submit']) || isset($_POST['COD'])) {
// handle textarea
if (isset($_POST['Submit'])) {
header("Location: Pay.php");
exit();
}
header("Location: cod.php");
exit();
}
?>
这是我的代码:
<form name="form1" onsubmit="return validate()" method="POST" class="contact-form">
<input type="hidden" name="command" />
<div class="col-sm-12">
<p align="center" class="contact-form-author">
ORDER TOTAL : Rs. <?php echo get_order_total()?>
</p>
</div>
<div class="col-sm-12">
<p class="contact-form-author">
<input type="hidden" value="<?php echo get_order_total()?>.00" name="price" placeholder="Name">
</p>
</div>
<div class="col-sm-12">
<p class="contact-form-author">
<input type="text" required="required" name="name" placeholder="Name">
</p>
</div>
<div class="col-sm-12">
<p class="contact-form-author">
<input type="text" required="required" name="address" placeholder="Address">
</p>
</div>
<div class="col-sm-12">
<p class="contact-form-email">
<input type="email" required="required" name="email" placeholder="Email">
</p>
</div>
<div class="col-sm-12">
<p class="contact-form-subject">
<input type="text" required="required" name="phone" placeholder="Phone">
</p>
</div>
<div class="col-sm-12">
<p>
<button class="viewlist" value="Place Order" type="submit" name="Submit">Online Payment</button>
<button class="viewlist" value="Place Order" type="submit" onclick="window.location='cod.php'" name="COD">Cash On delivery</button>
</p>
</div>
</form>
答案 0 :(得分:0)
您可以将表单提交到第一个PHP脚本,更改目标并将其发送到第二个脚本。
HTML:
' You can add TootTip1 in design time and set its properties.
' Then, call the following line on Form_Load or even set it ad design time if you want.
ToolTip1.SetToolTip(FlowLayoutPanel1, "Hello world!")
Private Sub FlowLayoutPanel1_ControlAdded(sender As Object, e As ControlEventArgs) Handles FlowLayoutPanel1.ControlAdded
ToolTip1.SetToolTip(e.Control, ToolTip1.GetToolTip(FlowLayoutPanel1))
End Sub
Javascript:
<form id="MyForm" action="Pay.php" target="Frame">
...
<input type="button" onClick="SendToBoth()" value="Send">
</form>
<iframe name="Frame" style="display: none;"></iframe>
如果要显示“ Cod.php”输出,则可以通过以下方式从“表单”第二提交之前删除“目标”:
function SendToBoth(){
var Form = document.getElementById("MyForm");
Form.submit(); // submitting to Pay.php
Form.action= "Cod.php";
Form.submit(); // submitting to Cod.php
}