Reputation: 9
what i should do to redirect to another page? what i have in comments are failed tries.
case 6:
//$redirectLocation = "http://www.productionportugal.com/blog";
// header'Location: ' . $redirectLocation); assume it like homepage
//include '/blog/index.php';
//include 'blog/index.php'; database error
//ini_set('include_path', '/blog');
//set_include_path('/blog');
// include_path=".:/blog" white page
// include="/blog/index.php"
// $redirectLocation = "http://www.productionportugal.com/blog";
require_once dirname(__FILE__) . '/Blog.php';
$_blog = new Blog();
$menuL = $_blog->getMenu();
$conteudo = "<div class='container' id='blogMenu'>
<div class='titulo'>$nome
<div class='btn-group'>
<a href='#' data-toggle='dropdown' id='dropdownBlog'>
<span class='caret'></span>
</a>
<ul class='dropdown-menu' aria-labelledby='dropdownBlog' role='menu'>
$menuL
</ul>
</div>
<a class='sprite leftS' id='prevLatestBlog'></a><a class='sprite rightS' id='nextLatestBlog'></a></div>
</div>";
$conteudo .= $_blog->getALL();
break;
Upvotes: 0
Views: 2928
Reputation: 30
This should solve your problem.
When pressing the button, the url will open as a new tab, without closing the current page you pressed the button on.
<!--HTML-->
<button type="submit" onclick="openExt('URL GOES IN HERE')"></button>
<!--JavaScript-->
<script type="text/javascript">
function openExt(url) {
window.open(url, "_blank");
}
</script>
Upvotes: 0
Reputation: 357
use
header("Location: ".$website);
to redirect to other pages.
see: http://php.net/manual/en/function.header.php
Edit: After you explain that you want a button that will do it onclick.
You can add this code:
window.location.href = "http://www.productionportugal.com/blog";
to the button onclick command to redirect when you click on button.
Upvotes: 1
Reputation: 162
If I have understood your question correctly than the below code will help:
header("Location: http://www.example.com/");
You can submit any url
Reference: http://php.net/manual/en/function.header.php
Also please note that header must appear in code before any output
Upvotes: 0
Reputation: 1139
You send a header, with your destination url
.
<?php
$newUrl = "http://www.productionportugal.com/blog";
header('Location: '.$newURL);
?>
It's as easy as that.
Note it will give an error if the headers are already send. Here is a detailed answer to how that works: headers
Upvotes: 0