Skip to content
Advertisement

How to Print a Message in html After Successfully Sending an Email Using a PHP mailer?

I’m using PHP mailer to my html contact form using action=”mail.php”. Well, I took the code from a youtube tutorial, my only problem is with this line of code <?php print r($message);?> in order for this line of code to work, the index file must be.php so I must use form method="post" enctype="multipart/form-data" instead of action=”mail.php” I tested it and it worked perfectly; I received a print message at the top of the contact form after pressing the send button. However, if I separate the PHP configuration and link it to my html contact form, the form will still perform and I will receive the email, but the print message will not appear because it is html. Please find the following code.

JavaScript

Advertisement

Answer

Put the message in session and after submit the form redirect to the curent page and show the message saved in the session and after that clear that session message (a flash message).

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement