简体   繁体   English

在返回到html页面后,如何在表单提交后显示echo?

[英]How do I display echo after form submit on return to html page?

This will show the echo on a blank white page. 这将在空白页面上显示回声。

$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'); */
}

I want to show the echo under the submit button on the main html page. 我想在主html页面上的提交按钮下显示回显。 Is using the URL a good way and how do I do it? 使用URL是一种好方法,我该怎么做?

Is using the URL a good way and how do I do it? 使用URL是一种好方法,我该怎么做?

I think that's a good solution, so the code would look like this: 我认为这是一个很好的解决方案,所以代码看起来像这样:

$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');
}

and then you can do this right below the button submit button in your form : 然后您可以在form中的按钮submit按钮下方执行此操作:

<?= if (isset($_GET["email"]) && $_GET["email"] == "exists") { echo "email already exists"; } ?>

You can use AJAX to do that. 你可以使用AJAX来做到这一点。

Take a look at this example: 看看这个例子:

http://www.w3schools.com/ajax/tryit.asp?filename=tryajax_first http://www.w3schools.com/ajax/tryit.asp?filename=tryajax_first

You can start with the basics here http://www.w3schools.com/ajax/default.asp and then learn how to use the $_POST method to your specific case: 您可以从http://www.w3schools.com/ajax/default.asp开始学习基础知识,然后学习如何在特定情况下使用$ _POST方法:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM