title: How to change the 'echo' position in php?
body: <p>1.I have created a login form and want to display username already in use please select another name. Want to change the position of echo in php. I have written echo in php code but i want to display that echo in html. How to display that?</p>
  
  <pre><code>&lt;?php
  
      if (isset($_POST["sign_up"])) {
          $fname = $_POST["first_name"];
          $lname = $_POST["last_name"];
          $email = $_POST["email"];
          $user = $_POST["username"];
          $password = $_POST["password"]; 
          $login_id = $row["login_id"];
          $sql_email = "SELECT email FROM login WHERE email='$email'"; 
          $email_result = mysqli_query($conn, $sql_email); 
          $email_num = mysqli_num_rows($email_result);
          if ($email_num != 0) { //If there is already such username... // 
              $email_echo = '&lt;span style="color:#e60000;text-align:center;"&gt;"There is user with that email.&lt;/span&gt;'; // ...kill the script!
              $email_echo = 'There is user with that email.'; 
          } else { //conti 
              $sql_signUp = "INSERT INTO login(first_name, last_name, email, username, password ) 
              values('$fname', '$lname', '$email', '$user', '$password')"; mysqli_query($conn, $sql_signUp); 
          } 
  
          $sql_username = "SELECT username FROM login WHERE username='$user'"; //looking through existing usernames 
          $username_result = mysqli_query($conn, $sql_username); 
          $username_num = mysqli_num_rows($username_result);
  
          if ($username_num != 0) { //If there is already such username... 
              $username_echo = '&lt;span style="color:#e60000;text-align:center;"&gt;"There is user with that username.&lt;/span&gt;'; // ...kill the script! 
          } else { //conti 
              $sql_signUp = "INSERT INTO login(first_name, last_name, email, username, password ) values('$fname', '$lname', '$email', '$user', '$password')";
              mysqli_query($conn, $sql_signUp); 
          } 
      }
  
  ?&gt;
      &lt;div id="signup"&gt;
         &lt;h1&gt;Sign Up&lt;/h1&gt;
         &lt;form action="&lt;?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?&gt;" method="post"&gt;
            &lt;div class="top-row"&gt;
               &lt;div class="field-wrap"&gt; &lt;label&gt; First Name&lt;span class="req"&gt;*&lt;/span&gt; &lt;/label&gt; &lt;input type="text" required autocomplete="on" name="first_name"/&gt; &lt;/div&gt;
               &lt;div class="field-wrap"&gt; &lt;label&gt; Last Name&lt;span class="req"&gt;*&lt;/span&gt; &lt;/label&gt; &lt;input type="text"required autocomplete="on" name="last_name"/&gt; &lt;/div&gt;
            &lt;/div&gt;
            &lt;div class="field-wrap"&gt; &lt;label&gt; Email Address&lt;span class="req"&gt;*&lt;/span&gt; &lt;/label&gt; &lt;input type="email"required autocomplete="on" name="email"/&gt; &lt;?php echo $email_echo //display some PHP here?&gt; &lt;/div&gt;
            &lt;div class="field-wrap"&gt; &lt;label&gt; Username&lt;span class="req"&gt;*&lt;/span&gt; &lt;/label&gt; &lt;input type="text" required autocomplete="on" name="username"/&gt; &lt;/div&gt;
            &lt;div class="field-wrap"&gt; &lt;label&gt; Set A Password&lt;span class="req"&gt;*&lt;/span&gt; &lt;/label&gt; &lt;input type="password"required autocomplete="off" name="password"/&gt; &lt;/div&gt;
            &lt;button type="submit" class="button button-block" value="sign_up" name="sign_up"/&gt;Register&lt;/button&gt; 
         &lt;/form&gt;
      &lt;/div&gt;
  </code></pre>