PHP - OB issues like template and forms
up vote
0
down vote
favorite
I have a view / template system, what it basically does is import and implement the files incorporating the local and global variables, I am currently using the Output Buffer (OB), however I have a problem, if the page / template has a form, when submitting the page is blank, that is, the template is no longer included, I believe it is a buffer problem, can someone tell me what the problem is?
Here is my Render class:
class View
{
public function render($file)
{
if(file_exists($file)){
extract((array) $this);
ob_start();
include $file;
return ob_get_clean();
}
}
}
This is my View class
class LoginView extends View
{
public function __construct()
{
$this->render(ROOT.'/public/layout/login.php');
}
}
And this is my template:
<!DOCTYPE html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="screen" href="main.css" />
<script src="main.js"></script>
</head>
<body>
<form method="POST" action="/">
<div class="input-field">
<label for="ipt-email">Email</label>
<input type="text" name="email" id="ipt-email">
</div>
<div class="input-field">
<label for="ipt-password">Senha</label>
<input type="text" name="password" id="ipt-password">
</div>
<button>Logar</button>
</form>
</body>
php view rendering output-buffering
add a comment |
up vote
0
down vote
favorite
I have a view / template system, what it basically does is import and implement the files incorporating the local and global variables, I am currently using the Output Buffer (OB), however I have a problem, if the page / template has a form, when submitting the page is blank, that is, the template is no longer included, I believe it is a buffer problem, can someone tell me what the problem is?
Here is my Render class:
class View
{
public function render($file)
{
if(file_exists($file)){
extract((array) $this);
ob_start();
include $file;
return ob_get_clean();
}
}
}
This is my View class
class LoginView extends View
{
public function __construct()
{
$this->render(ROOT.'/public/layout/login.php');
}
}
And this is my template:
<!DOCTYPE html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="screen" href="main.css" />
<script src="main.js"></script>
</head>
<body>
<form method="POST" action="/">
<div class="input-field">
<label for="ipt-email">Email</label>
<input type="text" name="email" id="ipt-email">
</div>
<div class="input-field">
<label for="ipt-password">Senha</label>
<input type="text" name="password" id="ipt-password">
</div>
<button>Logar</button>
</form>
</body>
php view rendering output-buffering
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a view / template system, what it basically does is import and implement the files incorporating the local and global variables, I am currently using the Output Buffer (OB), however I have a problem, if the page / template has a form, when submitting the page is blank, that is, the template is no longer included, I believe it is a buffer problem, can someone tell me what the problem is?
Here is my Render class:
class View
{
public function render($file)
{
if(file_exists($file)){
extract((array) $this);
ob_start();
include $file;
return ob_get_clean();
}
}
}
This is my View class
class LoginView extends View
{
public function __construct()
{
$this->render(ROOT.'/public/layout/login.php');
}
}
And this is my template:
<!DOCTYPE html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="screen" href="main.css" />
<script src="main.js"></script>
</head>
<body>
<form method="POST" action="/">
<div class="input-field">
<label for="ipt-email">Email</label>
<input type="text" name="email" id="ipt-email">
</div>
<div class="input-field">
<label for="ipt-password">Senha</label>
<input type="text" name="password" id="ipt-password">
</div>
<button>Logar</button>
</form>
</body>
php view rendering output-buffering
I have a view / template system, what it basically does is import and implement the files incorporating the local and global variables, I am currently using the Output Buffer (OB), however I have a problem, if the page / template has a form, when submitting the page is blank, that is, the template is no longer included, I believe it is a buffer problem, can someone tell me what the problem is?
Here is my Render class:
class View
{
public function render($file)
{
if(file_exists($file)){
extract((array) $this);
ob_start();
include $file;
return ob_get_clean();
}
}
}
This is my View class
class LoginView extends View
{
public function __construct()
{
$this->render(ROOT.'/public/layout/login.php');
}
}
And this is my template:
<!DOCTYPE html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="screen" href="main.css" />
<script src="main.js"></script>
</head>
<body>
<form method="POST" action="/">
<div class="input-field">
<label for="ipt-email">Email</label>
<input type="text" name="email" id="ipt-email">
</div>
<div class="input-field">
<label for="ipt-password">Senha</label>
<input type="text" name="password" id="ipt-password">
</div>
<button>Logar</button>
</form>
</body>
php view rendering output-buffering
php view rendering output-buffering
asked Nov 19 at 16:08
Vinicius Guerato
94
94
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53378578%2fphp-ob-issues-like-template-and-forms%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown