Answer the question
In order to leave comments, you need to log in
Is it bad to output html like this?
<?php
if (isset($_POST['register'])) {
$user = mysqli_fetch_assoc(mysqli_query($connection, "SELECT * FROM `users` WHERE `email` = '" . $_POST['email'] . "'"));
if ($user) {
echo '<p class="error">This email address is already associated with an account.</p>';
}
}
?>
<?php
if (isset($_POST['register'])) {
$user = mysqli_fetch_assoc(mysqli_query($connection, "SELECT * FROM `users` WHERE `email` = '" . $_POST['email'] . "'"));
if ($user) {
?>
<p class="error">This email address is already associated with an account.</p>
<?php
}
}
?>
Answer the question
In order to leave comments, you need to log in
Both options are bad.
It implies that the output goes directly mixed with queries to the database. And you must first execute all queries, collect all the data for output, and only then start outputting.
<?php
if (isset($_POST['register'])) {
if ($user) {
$error = "This email address is already associated with an account.";
}
// остальные проверки
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question