单击按钮后刷新页面


Refresh page after button is clicked

我在当前页面中有一个按钮 http://localhost/checkout/purchase-confirmation/?payment_key=97de4a39e2a8c732e686d7414ff5951a

<form method="POST" action=''>
  <input type="submit" name="deliver_confirmation"  value=" Tôi đã nhận được đồ. Tôi đồng ý trả tiền cho Người Mua Hộ">
</form>

单击它时,它会执行诸如发送电子邮件,更新数据库之类的操作。最后,刷新页面。

if (isset($_POST['deliver_confirmation']))
{
//Update payment meta of deliver_status
  $meta['deliver_status']= 'Đã giao hàng';
  edd_update_payment_meta( $payment->ID, '_edd_payment_meta', $meta);?>
//Refresh page 
  <meta http-equiv='refresh' content='0;"<?php get_permalink( $payment->ID); ?>"'>
}                   
?>

问题是,刷新页面后,它被重定向到

http://localhost/checkout/purchase-confirmation/"

这是"找不到"页面错误。我不明白重定向网址的"字符来自哪里。

有没有更好的方法来刷新页面?也许添加一些javascript,或者等等...

试试这个

<?php
echo '<META http-equiv="refresh" content="0;URL='.get_permalink( $payment->ID).'">';
?>

您实际上可以使用header()

header (Location: get_permalink( $payment->ID));

否则,如果要使用 meta refresh ,它应该是:

echo "<meta http-equiv='refresh' content='0; url=" . get_permalink( $payment->ID) . "'>";