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. Is using the URL a good way and how do I do it?
Is using the URL a good way and how do I do it?
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
:
<?= if (isset($_GET["email"]) && $_GET["email"] == "exists") { echo "email already exists"; } ?>
You can use AJAX to do that.
Take a look at this example:
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: