php - Stop user from viewing page if condition is not met -


hi appologies if has been answered can not find clear answer question.

lets have 2 pages, called fruit.php , salad.php

when user has entered data fields fruit.php directed salad.php nothing prevents user typing salad.php browser open second page , give wrong results because data page1, fruit.php has not been entered.

any idea how can stop user accesing salad.php before fruit.php completed?

in such case can this: since user expected enter values in 1st page (form) presenced there, let's one:

fruit.php

<form name="fruit" id="fruit" action="salad.php" method="post"> first component: <input type="text" name="component1"> second component: <input type="text" name="component2"> <input type="submit" value="check"> </form> 

now second page:

salad.php

<?php //first thing first, we're going check whether user //is being redirected form doing if ($_server['request_method'] == 'post') { //do } else { //this thing redirect user former page in case no form applied header('location: fruit.php') or die('unexpected error'); } ?> 

i hope assist you, there many ways , recommended check (empty(field)) before processing data avoid unpleasant results


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -