i have a working php contact form so when my message sends i get a thank you message. the issue is that the message shows at the top of the page when i want it to show above or below the submit button. i tried putting the success code there but then it just shows all the time on load. Is there a way to get it to show where i want it to?
<?php
session_start();
$to = 'zoeharriso@gmail.com';
$subject = 'New Message Recieved!';
$from = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$name = $_POST['name'];
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Create email headers
$headers .= 'From: '.$from."\r\n".
'Reply-To: '.$from."\r\n" .
'X-Mailer: PHP/' . phpversion();
// Compose a simple HTML email message
$message = "$message \r\n |
From $name \r\n |
Tel: $phone";
// Sending email
if(mail($to, $subject, $message, $headers)){
echo 'Your message has been sent successfully.';
} else{
echo 'Unable to send email. Please try again.';
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Drawings </title>
<link rel="stylesheet" href="style.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.0/css/all.css" integrity="sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<section id="section-1" class="pt-page-moveFromBottom">
<div id="contact-container">
<!--arrow up-->
<div class="nav-arrow" style="margin-top:30px;">
<a href="gallery.html"><i class="fas fa-chevron-up orange"></i><span class="orange">Gallery</span></a>
</div>
<!--titles-->
<h1 id="contact-title">paul<span id="contact-title2">warren</span></h1>
<h2 id="contact-subtitle">drawings</h2>
<!--contact form-->
<div id="contact-form-container">
<p class="contact-text">The unframed prints, C print or Giclée,are available on archival quality paper, in a variety of sizes, may be ordered or further information may be obtained by sending me a message.</p>
<form id="form" method="POST" action="contact.php">
<div class="row2">
<div class="col2">
<input type="text" id="name" name="name" placeholder="Name" required>
<input type="text" id="email" name="email" placeholder="Email" required>
<input type="text" id="phone" name="phone" placeholder="Phone">
</div>
<div class="col2">
<textarea id="message" name="message" placeholder="Your message" required></textarea>
</div>
</div>
<div>
<!--SUCCESS MESSAGE HERE-->
</div>
<div class="row2">
<button type="submit" id="submit">Send</button>
</div>
</form>
```