I am trying to process html form which is in file something.php. This page will have <div>Thanks for submitting the form</div> hidden by CSS
div {
display: none;
}
On the successful submit I will like to display this message by setting display: block for example but the problem i am finding is that on submit this page (something.php) refreshes and my message from above immediately disappears. Is there any way I can resolve this without using different.php script or Ajax?
As far as I know, when you do a form submit, whether it’s to the same PHP source file or to another one, you’ll get a page refresh which is what I don’t think you want. So the alternative is that you use Ajax to submit the form, set your div to ‘block’ at the start of the button handling code, and then deal with whatever response comes from the separate PHP code. I guess you could have it in the same file but I can’t see why you’d want to.