MV framework logo
  • Architecture
    • Philosophy
    • Technologies
  • Admin Panel
  • Changelog
  • Support
  • Feedback
Download Version 2.6 from 07.10.2022
Documentation
  • Architecture
    • Philosophy
    • Technologies
  • Admin Panel
  • Changelog
  • Support
  • Feedback
Getting started
  • Installation and launch
  • System folders
  • Launch of simple website
  • Pre-installed models
  • System settings
Models
  • General principles of models
  • Data types
  • Model settings
  • Simple models
  • Foreign keys
  • Trees
  • Many to many
  • Group
  • Records management
  • Simple model management
  • Additional options
Views and routes
  • General principles of views
  • Router object
  • MV object
  • Index, default and 404 templates
  • Creating a new template
  • Data display in template
  • Object of Record class
  • Files and images
  • Date and time
  • Redirects
  • Email delivery
  • Special methods
Forms
  • Forms creation
  • Form fields settings
  • Form validation rules
  • Form validation process
  • Operations with form data
  • Using data from models
  • Form methods
SQL queries
  • Query constructor
  • Direct queries
  • Pagination
  • Sorting
  • Filtration
  • Upload from CSV files
Sessions and security
  • Work with sessions
  • AJAX
  • Security
  • Debugging
Plugins
  • General principles of plugins
  • Additions to admin panel
  • Caching
Documentation
Getting started
  • Installation and launch
  • System folders
  • Launch of simple website
  • Pre-installed models
  • System settings
Models
  • General principles of models
  • Data types
  • Model settings
  • Simple models
  • Foreign keys
  • Trees
  • Many to many
  • Group
  • Records management
  • Simple model management
  • Additional options
Views and routes
  • General principles of views
  • Router object
  • MV object
  • Index, default and 404 templates
  • Creating a new template
  • Data display in template
  • Object of Record class
  • Files and images
  • Date and time
  • Redirects
  • Email delivery
  • Special methods
Forms
  • Forms creation
  • Form fields settings
  • Form validation rules
  • Form validation process
  • Operations with form data
  • Using data from models
  • Form methods
SQL queries
  • Query constructor
  • Direct queries
  • Pagination
  • Sorting
  • Filtration
  • Upload from CSV files
Sessions and security
  • Work with sessions
  • AJAX
  • Security
  • Debugging
Plugins
  • General principles of plugins
  • Additions to admin panel
  • Caching

Redirects

In "$mv" object there are methods available to reload and redirect from one URL to another. All of them are using the "header()" function and ending with "exit()" function call.

Reload of the current page - reload()

This method reloads the current page and allows to add extra parameters to URL. The initial GET parameters will be removed. If no parameters were passed to the method, then the current page will be reloaded without old GET parameters.

//If the form is filled without errors, reload the current page and add GET parameter 
if($form -> isValid())
{
    ...

    $mv -> reload("?message-sent=1");
}

Redirect to other pages - redirect()

This method is used for redirecting to other page. If it is called without parameters, then redirect goes to the website root (to main page). It is possible to add both parts of links and GET parameters.

//If a user is not authorized, redirect to login page 
if(!$mv -> clients -> checkAuthorization())
    $mv -> redirect("login/");

//If registration form is filled correctly, then redirect 
//and if we possibly need to redirect user right to order submit 
if($form -> isValid())
{
    ...

    $path = isset($_GET['from-order']) ? "order/?continue" : "registration/complete/";
    $mv -> redirect($path);
}

404 Error

If the requested page can't be found in URL configurations (more details in General principle of templates section), then in MV an own page of 404 error will be shown. The included file is located in "views" folder and by default has "view-404.php" name. When redirecting to 404 page, an additional HTTP header will be sent "HTTP/1.1 404 Not Found".

The "display404()" method may also accept a parameter. If this parameter is positive, then the redirect won't occur.

//If the product not found, show 404 error
$content = $mv -> products -> findRecord(array("url" => "interesting-book", "active" => 1));
$mv -> display404($content);
 
//If the get the product ($content variable is not false), then continue to display the page

Previous section

Date and time

Next section

Email delivery

© 2012-2023, MV framework

MV tracker is based on open source MV framework
License