this question is really in two parts but they're relevant to each other _ i have created a contact form and want to give the form user a response message _ currently the message either appears at the top of the page or on a new page which forces me to tell the user to continue by pressing the back button _ i would like the message response to appear under the form AND (if it's possible!) allow the user to read the form response & continue browsing without having to do anything _ i am not very conversant with php but have gone through some answers i found on stack overflow and came up with this:
if (mail ($to, $subject, $body, $from)) {
echo '<div class="formOutput">'.'<p>Thank you for your email!<br />Please press your Back Button to continue</p>'.'</div>';
} else {
echo '<div class="formOutput">'.'<p>An error occurred. Please try sending your message again.<br />Please press your Back Button to continue</p>'.'</div>';
}
i then set div with class 'formOutput' underneath the form 'submit' button
<input type="submit" value="Submit" name="submit">
</form>
<div class="formOutput" style="height: 50px;"></div>
unfortunately this has not worked _ the response messages are either appearing at the top of the page or on a new page _ depending on where i test the form _
as previously stated i would also like (if possible!) the form user to be able to read the response and then continue browsing without having to press 'back button' or anything else
thanks in advance for any assistance : )
i checked out another answer on stack overflow which covers part of the problem by setting the form action with a hash-tag which redirects to a specified element ID _ Contact Form Thank You Top of Page
however i'm not sure if it's possible or how this could be added to the action code i already have in my form =
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="POST">
answers relevant to the actual issue (rather than comments about the question formatting!) would be greatly appreciated _ thanks