e107help.org Q&A
0 like 0 dislike
I am a newby of about 7 hours poking around experience.

I want to write Php pages that access a separate database into an e107 managed site. and I obviously want to use the same themes

How can I do this?
e107 version Version 2.1.9
closed with the note: solved
asked in Other by (20 points) 2
closed by

1 Answer

0 like 0 dislike
Best answer

yes thats pretty easy... heres an example

first create a file called blank.php,  the top part & bottom of the code includes get template, it will create a page almost identical to custom pages. The portion of code that is quoted is the database code, I use a seperate customer database that paypal can update to keeps track of payments made

<?php
require_once("class2.php");
require_once(HEADERF);
$ns->tablerender("Subscription Information", "");

 

 

// display customer notes


// Create connection
require_once("config.php");
$conn = new mysqli($servername, $username, $password);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);


// open connection
$conn = new mysqli($servername, $username, $password, $dbname);

// test  connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);

$sql = "SELECT payments FROM customers";
$result = $conn->query($sql);


if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) 
 {
echo "<br />";

$notes = $row["payments"]. "";
echo $payments;

    }

else 
  {
  echo "No payments posted";
  }

$conn->close();

 

// include the template footer & routines

require_once(FOOTERF);
exit;

 

 

hope it helps

answered by (30 points)
selected by
Ah! my problem is with .htaccess,

I could get around the issue by diabling the deny

# secure htaccess file
<Files .htaccess>
#    order allow,deny
#    deny from all
</Files>

However, I very much doubt if that is the wisest way of acheiving this. As I do not want my punters having access.

Advice welcome.

You are messing static and dynamic pages.  In admin area you have static pages when can you add content. Mainly text, html and some script is allowed. 

Then you use standalone page (normal php file), where you include e107 stuff  in header and footer (. Inside it you can use your code.  And you always can look into _blank plugin, but advice above (from akamolik) is full and correct.

Or you can create plugin if you need admin area for this.  There is plugin builder for this.

Here is small example with source code how to do it (but there goal was menu not main plugin page, but it's similar). 

https://www.e107.sk/forum/tutorial/78/how-to-create-simple-plugin/

And you can use wrapper plugin by Moc too and include your code inside e107 via iframe. 

 

 

I use this method since it gives full power of php and other scripts, I create new pages in cpanel filemanger then create a link to them

You really cannot create php pages (or add code) from custom pages created in the admin panel, those are limited to simple html content.
Thanks that is a helpful straight forward answer to how to write custom PHP pages, Someone else has answered the other simple part which was how to make a plugin to add items to the theme menus.
Welcome to e107 Q&A, where you can ask questions and receive answers from other members of the e107 community.
798 questions
1,203 answers
2,074 comments
932 users