Jump to content

is there any method to prevent a page access directly?


adrianmak
 Share

Recommended Posts

There is a page name thank-you page, which is used for all submission form, a success submission will redirect to this thank-you page.

I would like to stop people to access this page directly and checking if it is not redirect from other page with form submission, it will redirect to home page automatically.

 

 

 

Link to comment
Share on other sites

Hi @adrianmak

When you make redirect from your form to "thank you" page, you can add some get parameter to the link like:

thank-you/?submit=success and then in "thank you" page template check if there this get parameter, if not - redirect to homepage.

  • Like 2
Link to comment
Share on other sites

If I understand correctly, that a successful form submission is then redirected to /thank-you/, I would use $session. Then you could do something like this

<?php

// Form A

if($success){
  $session->formSuccess = 'formA';
}

// or 'formB' etc on any other forms

// then redirect to /thank-you/

and then

<?php 

// /thank-you/

if($session->formSuccess){
  switch($session->formSuccess){
    case 'formA':
      $message = 'Thanks for submitting Form A';
      break;
    case 'formB':
      // etc
  }
  $session->formSuccess = '';
} else {
  //redirect to /home/ or wherever
}
  

 

  • Like 5
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...