MyBB Community Forums

Full Version: PHP in a Custom page with Mybb
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
@.m. Check your pm.
What .m. said, also no idea why you place the PHP inside the page template? Should be (made it also cleaner and using MyBB templates):
<?php
define('IN_MYBB', 1); // (1a)
require "./global.php"; // (1b)

global $mybb;

add_breadcrumb("Test Custom page", "testpage_c.php"); // (2)

$msg = $mybb->input["msg"];
$name = $mybb->input["name"];
if(!empty($msg)) {
    $posts = "$msg - $name\n";
}

$template = '
 <html>
 <head>
 {$headerinclude}
 <title>Test Page</title>
 </head>

<body>
{$header}
 <form id="form1" name="form1" method="post" action="">
 <label>Please type in a message
 <input class="textbox" type="text" name="msg" id="msg" />
 </label>
 <label>and your name
 <input class="textbox" type="text" name="name" id="name" />
 </label>

 <p>
 <label>Submit
 <input class="button" type="submit" name="submit" id="submit" value="Submit" />
 </label>
 </p>
 </form>
{$posts}
{$footer}
</body>
</html>';

$template = str_replace("\'", "'", addslashes($template));
eval("\$testpage=\"".$template."\";");
output_page($testpage);
?>

Tested, works.

Edit@down, wait what? No idea what you're talking about, the output of the echo function used previously in an incorrect way is moved inside the template as {$posts} variable and you can move it wherever you want.
Thanks bro, this will work though. The echoed output will come at top of the page above the $template content.

I haven't quite well observed the misplaced php code above as I have done that in localhost (not with the mybb). And so now, how can I place the echoed output just under the form.
You can't test page for MyBB without MyBB... global.php is required in 3rd line so nothing is going to work without that file.

Read the edit to my previous post to know how to move the output, still I don't think you even tried my code because the message and name are right below the form in the template I posted.
@Destroy666, check your pm
Pages: 1 2