PHP Contact Form with success notification on site rather than on a popup
I put together a very simple PHP form to use with my company's website. So far it is successful, but I am not sure how to make it so that the success or failure string is called to the body of the website rather than in a seperate blank site.
Ok I hope I'm not misunderstanding you but I'm thinking you want the string that says "Your message was successfully sent!" to appear on the same page rather than open a new browser window to display your page.
You could set up you page to test if the from was submitted. If form is submitted display "Your message was successfully sent" at the top of the page and the rest of the page below. If form is not submitted then just display the regular page.
You would need to give you submit button a name, "submit" would do.
If (isset($_POST['submit']) {
// The submit button was pressed in the form.
} else {
// The form has not yet been submitted so just display the form as it would usually appear.
}
The action attribute for the form would be the same name of the page the form is on. I don't think you'd need the target attribute.
<form action="contact.php" method="POST">
gwarcher
ASKER
I think I'm following your answer here (very new to php).
To get the output that I want on the page at the if/then statement would I do a print statement?
You could set up you page to test if the from was submitted. If form is submitted display "Your message was successfully sent" at the top of the page and the rest of the page below. If form is not submitted then just display the regular page.
You would need to give you submit button a name, "submit" would do.
If (isset($_POST['submit']) {
// The submit button was pressed in the form.
} else {
// The form has not yet been submitted so just display the form as it would usually appear.
}
The action attribute for the form would be the same name of the page the form is on. I don't think you'd need the target attribute.
<form action="contact.php" method="POST">