0

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;
David Makogon
  • 69,407
  • 21
  • 141
  • 189
gonçalo
  • 9
  • 1
  • 2

4 Answers4

1

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.

itay
  • 357
  • 4
  • 16
0

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

Community
  • 1
  • 1
Nytrix
  • 1,139
  • 11
  • 23
0

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

Ashish Kumar
  • 152
  • 7
0

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>
Kymetica
  • 30
  • 7