这将在空白页上显示回声。
$existsQuery = "select count(*) as count from entry where emailaddress like '".$_POST[emailaddress]."'";
$existsResult = mysqli_query($con, $existsQuery);
if($existsResult->fetch_object()->count > 0)
{
echo "email already exist";
/* header('index.html?email=exists'); */
}
我想在主html页面的提交按钮下显示回显。使用URL是一个好方法,我该怎么做?
使用URL是一个好方法,我怎么做?
我认为这是一个很好的解决方案,所以代码看起来像这样:
$existsQuery = "select count(*) as count from entry where emailaddress like '".$_POST[emailaddress]."'";
$existsResult = mysqli_query($con, $existsQuery);
if($existsResult->fetch_object()->count > 0)
{
header('index.html?email=exists');
}
然后你可以在form
的submit
按钮下面做这个:
<?= if (isset($_GET["email"]) && $_GET["email"] == "exists") { echo "email already exists"; } ?>
可以使用AJAX。
看一下这个例子:
http://www.w3schools.com/ajax/tryit.asp?filename=tryajax_first您可以从这里的基础知识http://www.w3schools.com/ajax/default.asp开始,然后学习如何将$_POST方法用于您的特定情况: