0

I'm trying to make a contact form replacement script. Users are able to put [contact-form] in their text editor and a contact form will appear. The script below works fine...

function ubbreplace($text){
    if (strpos($text, "[contact-form]") !== false) {
       ob_start();
       include("contactform.php");
       $replace = ob_get_contents();
       ob_end_clean();
       $text = str_replace("[contact-form]", $replace, $text);
    }
    return $text;
}

... but not for my project. Some did not know how to fix the issue with my code, so I'm trying to find a replacement for this. Other code with the same effect.

What can I do to safely and user friendly replace [contact-form] with include("contactform.php")?

Community
  • 1
  • 1
J. Doe
  • 503
  • 1
  • 6
  • 19
  • What is the probleme with your code ? – Sofiene Djebali May 20 '16 at 18:48
  • @SofieneDJEBALI Nothing really, but I want to find a replacement and I'm not sure what to use to replace `[contact-form]` with a PHP include. – J. Doe May 20 '16 at 18:49
  • ob_get_contents is working right ?, why do you wan't something else ? – Sofiene Djebali May 20 '16 at 18:50
  • @SofieneDJEBALI It's working but the code isn't suitable for my project. In `contactform.php` is database connection code. And with the code in my post, it doesn't connect. I've tried to solve that issue but nobody could get it working, so I'm looking for a replacement – J. Doe May 20 '16 at 18:53

0 Answers0