簡體   English   中英

錯誤消息顯示-Wordpress中的表單數據PHP條目

[英]Error Message Display - Form Data PHP Entry in Wordpress

當前,我們有一個PHP表單,該表單使用一個條目來重定向到主網站內的私有網站,我們使用以下代碼:

<?php
//Turn the content from text box into variable
$page=$_POST['text'];

if($_POST['text']=='sit') {
//set up a redirect to that page
echo "<meta http-equiv=\"refresh\" content=\"0;URL=http://example.com/index.php/private/sit\">";

}

else if($_POST['text']=='pony') {
//set up a redirect to that page
echo "<meta http-equiv=\"refresh\" content=\"0;URL=http://example.com/wp-content/uploads/sites/2/client/pony/index.html\">";

}

最初,我們實現了最后一行,如果有人插入了錯誤內容,它將刷新頁面:

else {
   echo "<meta http-equiv=\"refresh\"content=\"0;URL=http://example.com\">";

}
?>

如何在表格旁邊顯示粗體和紅色的“錯誤”消息?

您可以在用於刷新的URL中發送參數。 然后在用Javascript刷新URL后檢查參數並添加錯誤。

在這種情況下,您將回顯類似的內容

echo "<meta http-equiv=\"refresh\"content=\"0;URL=http://example.com?error=1\">";

然后在您的html中,使用Javascript或PHP檢查URL參數並使用樣式呈現錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM