[英]Redirect to New Page after Post Action
currently when my form is submitted 'Application Successful' text appears on the same page.目前,当我提交表单时,“申请成功”文本出现在同一页面上。 How do i get form to submit to a thank you page?
我如何获得表单以提交到感谢页面?
This is my code:这是我的代码:
<div role="form" class="col-lg-8" id="wpcf7-f4-p7902-o1" dir="ltr" lang="en-US">
<form action="<?php echo $apply_permalink; ?>" method="post">
<?php if($post_saved){ ?>
<div class="alert alert-success">Application Successful.</div>
<?php }?>
<p>
<label> Your Name & Surname (required)<br>
<span class="wpcf7-form-control-wrap your-name">
<input name="your-name" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required" aria-required="true" aria-invalid="false" type="text">
</span>
</label>
</p>
<p>
<label> Your Email (required)<br>
<span class="wpcf7-form-control-wrap your-email">
<input name="your-email" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-email wpcf7-validates-as-required wpcf7-validates-as-email" aria-required="true" aria-invalid="false" type="email">
</span>
</label>
</p>
<p>
<label> Your Cell Number<br>
<span class="wpcf7-form-control-wrap">
<input name="your-cell" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-email wpcf7-validates-as-required wpcf7-validates-as-number" aria-required="true" aria-invalid="false" type="text">
</span>
</label>
</p>
<p>
<input value="Apply" class="wpcf7-form-control" type="submit">
</p>
</form>
</div>
I've tried to look at other submission with the same problem but the code is different from mine so the solutions don't apply to mine.我试图查看其他提交的相同问题,但代码与我的不同,因此解决方案不适用于我的。
Thanks in advance.提前致谢。
header("Location: http://www.yourwebsite.com/user.php"); /* Redirect browser */
exit();
It is a good practice to call exit() right afterwords so that code below it does not get executed.紧接着调用 exit() 是一个很好的做法,这样它下面的代码就不会被执行。
<?php
if(isset($_POST['submitForm'])){
header('location: https://google.com/');
exit();
}
?>
It's important that you put this at the very top of the page, otherwise you can use JS重要的是你把它放在页面的最顶部,否则你可以使用 JS
<?php
if(isset($_POST['submitForm'])){
echo "<script>window.location.href='https://google.com';</script>";
}
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.