# 'Master Page' mechanism on php web-page must be revised

**URL:** <https://forum.pinegrow.com/t/master-page-mechanism-on-php-web-page-must-be-revised/2030>\
**Category:** Bug Reports\
**Tags:** bug\
**Created:** [July 5, 2018, 1:18pm UTC](https://forum.pinegrow.com/t/master-page-mechanism-on-php-web-page-must-be-revised/2030 "2018-07-05T13:18:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![micheleSaltori](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/michelesaltori/32/1146_2.png) [@micheleSaltori](https://forum.pinegrow.com/u/micheleSaltori)\
**Post date:** [July 5, 2018, 1:18pm UTC](https://forum.pinegrow.com/t/master-page-mechanism-on-php-web-page-must-be-revised/2030/1 "2018-07-05T13:18:49Z")

</div>

I’m using web-page in php and recently starting using the ‘Master Pages’ feature of PG, but…

The best pratice in php-page is starting file with instruction start\_session(); (or any other function managing session) to avoiding problem with some error or tips in the HTTP header.

**My ‘Master Page’.php starting:**

```auto
<!DOCTYPE html>
<html lang="it" data-pgc-set-master>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="User access security system, Sistema di accesso e autenticazione utente in php">
    <meta name="author" content="Michele Saltori (Italy) ~ tecnoinformatica@ivgw.eu">
    <title data-pgc-edit="SecMasterTitlePage">Master page per sistema di sicurezza</title>
    <!-- Bootstrap core CSS -->
    <style data-pgc-edit="SecMasterStyle"></style>
    <link href="bootstrap/css/bootstrap.css" rel="stylesheet">

```

**And my ‘slave page’.php …**

```auto
<?php
require_once('security_access.inc.php');
//require_once ('security_access_anonym.inc.php');
?>
<!doctype html>
<html lang="it" data-pgc-master="SecMaster.php">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="User access security system, Sistema di accesso e autenticazione utente in php">
    <meta name="author" content="Michele Saltori (Italy) ~ tecnoinformatica@ivgw.eu">

```

**After ‘PG component update’ the header part of file:**

```auto
<?php
require_once('security_access.inc.php');
//require_once ('security_access_anonym.inc.php');
?>

```

**Is removed!**

Outside of html code of page, ‘php block script’ cannot be inserted or/and marked as an editable area.

🙏 Why not implement script block outer html code on the ‘Master Page’?  
eg:

```auto
<?php /*data-pgc-field="SecMasterHeadScriptArea"*/
?>
<!doctype html>
<html lang="it" data-pgc-master="SecMaster.php">
<head>....

```

Please Help me and us (php developers).

_I’m using: PG 4.8 on Linux Mint LMDE 2 Cinnamon 64-bit, Apache2, PHP 5.6.36_

---

<div class="post-metadata">

**Author:** ![matjaz](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/matjaz/32/5_2.png) [@matjaz](https://forum.pinegrow.com/u/matjaz)\
**Post date:** [August 21, 2018, 1:20pm UTC](https://forum.pinegrow.com/t/master-page-mechanism-on-php-web-page-must-be-revised/2030/2 "2018-08-21T13:20:43Z")

</div>

@micheleSaltori why not adding this code to the master page?

\<?php require\_once(‘security\_access.inc.php’); //require\_once (‘security\_access\_anonym.inc.php’); ?\>

---

<div class="post-metadata">

**Author:** ![micheleSaltori](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/michelesaltori/32/1146_2.png) [@micheleSaltori](https://forum.pinegrow.com/u/micheleSaltori)\
**Post date:** [August 24, 2018, 4:33pm UTC](https://forum.pinegrow.com/t/master-page-mechanism-on-php-web-page-must-be-revised/2030/3 "2018-08-24T16:33:17Z")

</div>

@matjaz  
Yes you can insert php tag in master-page outside html (before the \<!DOCTYPE\> tag) same you suggest but if you need that php script never change in slave page, because any update of master-page the php tag are refreshed it.  
Following the correct code that you suggest:

```auto
<?php
   //fixed php statement not changable in slave page
?>
<!DOCTYPE html>
<html lang="en" data-pgc-set-master>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">
....

```

This not resolve my problem in wich I have necessity to insert different php-code in slave-page manipulating the http headers (e.g. php-session).

---

<div class="post-metadata">

**Author:** ![micheleSaltori](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/michelesaltori/32/1146_2.png) [@micheleSaltori](https://forum.pinegrow.com/u/micheleSaltori)\
**Post date:** [August 24, 2018, 4:58pm UTC](https://forum.pinegrow.com/t/master-page-mechanism-on-php-web-page-must-be-revised/2030/4 "2018-08-24T16:58:10Z")

</div>

👍👍👍  
Finally I resolved the problem in the following method:  
In master-page, after `<HTML>` and before the `<HEAD>` tags (area in which browser still has not altered any http header) I inserted one tag `<script>` defined as editable area in which insert any php script in their php-tag `<?php...?>`.

**-----\>Edit 27 aug 2018: NON VALID SOLUTION see topic below.**

See exemple bellow:

```auto
<!DOCTYPE html>
<html lang="en" data-pgc-set-master>
<script data-pgc-edit="phpscriptinhtmlscript">
<?php
   //editable area for php script (expecially for session and http-header)
?>
</script>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

```

This solution run fine. Any problem related to php-session and modify http-headers are solved.  
PHP-code in slave-page are preserved!  
🌞🌞🌞

---

<div class="post-metadata">

**Author:** ![micheleSaltori](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/michelesaltori/32/1146_2.png) [@micheleSaltori](https://forum.pinegrow.com/u/micheleSaltori)\
**Post date:** [August 27, 2018, 6:42am UTC](https://forum.pinegrow.com/t/master-page-mechanism-on-php-web-page-must-be-revised/2030/5 "2018-08-27T06:42:14Z")

</div>

@myself

> [@micheleSaltori](#):
>
> 👍👍👍  
> Finally I resolved the problem in the following method:  
> In master-page, after `<HTML>` and before the `<HEAD>` tags (area in which browser still has not altered any http header) I inserted one tag `<script>` defined as editable area in which insert any php script in their php-tag `<?php...?>`.
> 
> **-----\>Edit 27 aug 2018: NON VALID SOLUTION see topic below.**
> 
> See exemple bellow:
> 
> ```auto
> <!DOCTYPE html>
> <html lang="en" data-pgc-set-master>
> <script data-pgc-edit="phpscriptinhtmlscript">
> <?php
> //editable area for php script (expecially for session and http-header)
> ?>
> </script>
> <head>
> <meta charset="utf-8">
> <meta http-equiv="X-UA-Compatible" content="IE=edge">
> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
> <meta name="description" content="">
> <meta name="author" content="">
> 
> ```
> 
> This solution run fine. Any problem related to php-session and modify http-headers are solved.  
> PHP-code in slave-page are preserved!  
> 🌞🌞🌞

**Unfortunately my proposed solution fail in this condition:**  
If php-page is contained in an iframe object and the php included script make a redirect, rendering of page fail.  
Only solution is to place the php script with the ‘include’ option on the top of page (before the html tag DOCTYPE).  
**Therefore**  
my original issue (create a master php-page with inside an php script-tag on top of file wich can be edited in the slave page…) ❗ **still remain unresolved!**

---

<div class="post-metadata">

**Author:** ![matjaz](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/matjaz/32/5_2.png) [@matjaz](https://forum.pinegrow.com/u/matjaz)\
**Post date:** [August 27, 2018, 2:26pm UTC](https://forum.pinegrow.com/t/master-page-mechanism-on-php-web-page-must-be-revised/2030/6 "2018-08-27T14:26:26Z")

</div>

@micheleSaltori you can add a PHP code like this to the master:

```auto
<?php
if(basename( __FILE__ ) == 'index.php') {
    require_once 'mainpage.php';
} else {
    require_once 'slavepage.php';
}

```
