Avatar of BrighteyesDesign
BrighteyesDesign
Flag for Afghanistan asked on

Show sucees message on the same page as the form

I have an enquiry form that sends using a separate php script. When the forms sends a success message displays on a blank page. How can I get this message to display on the page with the actual form?

This is the part of the php script that deals with the success message

 // now we just send the message
   if (@mail($to, $subject, $message, $headers)) {
      echo "Thanks for sending your details. We will be in touch soon.";
   } else {
      echo "Failed to send";

Open in new window

  }
PHP

Avatar of undefined
Last Comment
BrighteyesDesign

8/22/2022 - Mon
Marco Gasi

As I can understand, the code portion you posted here belongs to the separate script which sends email and so when the message has been sent, it displays the success message in a blank page.

You should enclose the code of the separate script in a function you pass parameters to
and make this function return true or false. Based on this you should display the message in your original page.

Cheers
ASKER CERTIFIED SOLUTION
Marco Gasi

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
BrighteyesDesign

ASKER
Perfectly clear, thanks!
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23