PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hey guys and gals. I'm new to php so I'm working with a very basic template for making a contact form for my site. The html is solid I just had a question about the echo aspect of the php code i'm working with. I wanted to know if it was possible for the "message success" or "message fail" window that pops up after you click submit can be on a custom page instead of just displaying on a blank one.
This is what I'm working with
I'm not sure if I'm even explaining it correctly. I've been up all night on google trying to solve the problem for myself. Any help would be greatly appreciated.
If you want to display the success/fail message on your site's template, you need to add the template data (html tags) to your success/fail statement.
It might be easier to either create a seperate page or use the contact form itself. If you use the contact form, you could check (before displaying the contact form) to see if it has been submitted. If it has, display the message instead of the contact form. If it hasn't, display the contact form. You could check to see if it has been submitted by checking for the POST data. If it exists, the form has been submitted (providing your form uses POST).
I guess my question is what tags and where do I add them?
I just want to use my own sites html template so instead of the "your message has been successful" showing up on a new blank page, what exactly do I have to input into the .php in order to direct it there?
<?php
//Check to see if the contact form was submitted and then check to see if everything worked out right
include_once('includes/header.php');
if($success) {
echo '<h1>Success!</h1><p>Your message has been submitted</p>';
}else{
echo '<h1>Error</h1><p>There was an error while submitting the contact form. <a href="contact.php" title="Contact">Please try again.</a></p>';
}
include_once('includes/footer.php');
?>