#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    2
    Rep Power
    0

    Pass Variables to Next Page


    I have a search class with pagination and I can get the first page to display correctly but the next page gives a bunch of undefined index(s). I know i need to pass the variables to the next page but it uses one "View" and a "Class". Here is the search function.

    PHP Code:
    <?php  class Search extends MainController{
         function 
    __construct(){
                
    parent::__construct();
                 
    $this->view->url    $this->config->url;
                            
    $this->view->ID       get_class($this);
                 
    $this->view->Title "Diablo 3 Online Auction House";
                 
    $this->view->msg "";             $this->view->err false;
                   
    $itemName = isset($_POST['item_name']) ? $_POST['item_name'] : '';
                 
    $val_1 $_POST['attrib1'];
                 
    $val_2 $_POST['attrib2'];
                 
    $val_3 $_POST['attrib3'];
                 
    $val_4 $_POST['attrib4'];
                 
    $val_5 $_POST['attrib5'];
                 
    $val_6 $_POST['attrib6'];
                 
    $val_7 $_POST['attrib7'];
                 
    $val_8 $_POST['attrib8'];
                 
    $itemAttrib1 $_POST['list_1'];
                 
    $itemAttrib2 $_POST['list_2'];
                 
    $itemAttrib3 $_POST['list_3'];
                 
    $itemAttrib4 $_POST['list_4'];
                 
    $itemAttrib5 $_POST['list_5'];
                 
    $itemAttrib6 $_POST['list_6'];
                 
    $itemAttrib7 $_POST['list_7'];
                 
    $itemAttrib8 $_POST['list_8'];
                 
    $Quality $_POST['quality'];
                 
    $Type $_POST['type'];
                 
    $sub_Type $_POST['sub'];
                  
    $page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1;
                 
    // If the page wasn't set, lets set $page to number 1 for the first page

    // Lets set how many messages we want to display
                
    $per_page "5";

                
    // Now we must calculate the last page
                
    $last_page ceil($ctr/$per_page);

                
    // And set the first page
                
    $first_page "1";
                
                
    // Here we are making the "First page" link
                
    if ($page == $first_page){
                    
    $this->view->first "<li class='disabled'><a href='?page=".$first_page."'>First page</a></li>";
                }else{
                    
    $this->view->first "<li><a href='?page=".$first_page."'>First page</a></li>";
                }

                
    // If page is 1 then remove link from "Previous" word
                
    if($page == $first_page){               
                    
    $this->view->prev "<li class='disabled'><a>Previous</a></li>";                
                }else{              
                    if(!isset(
    $page)){                  
                        
    $this->view->prev "<li><a>Previous</a></li>";
                    }else{                  
                        
    // But if page is set and it's not 1.. Lets add link to previous word to take us back by one page
                        
    $previous $page-1;
                        
    $this->view->prev "<li><a href='?page=".$previous."'>Previous</a></li>";
                    }               
                }
                
                
    // If the page is last page.. lets remove "Next" link
                
    if($page == $last_page){                
                    
    $this->view->next "<li class='disabled'><a>Next</a></li>";
                }else{              
                    
    // If page is not set or it is set and it's not the last page.. lets add link to this word so we can go to the next page
                    
    if(!isset($page)){                  
                        
    $next $first_page+1;
                        
    $this->view->next "<li><a href='?page=".$next."'>Next</a></li> ";
                    }else{              
                        
    $next $page+1;
                        
    $this->view->next "<li><a href='?page=".$next."'>Next</a></li>";
                    }
                }

                
    // And now lets add the "Last page" link
                
    if ($page == $last_page){
                    
    $this->view->last "<li class='disabled'><a href='?page=".$last_page."'>Last page</a></li>";
                }else{
                    
    $this->view->last "<li><a href='?page=".$last_page."'>Last page</a></li>";
                }

                
    // Math.. It gets us the start number of message that will be displayed
                
    $start = (($page $per_page) - $per_page);

                
    // Now lets set the limit for our query
                
    $limit "LIMIT $start$per_page";
                
    $this->view->msg "Successful Search";
                    
    $this->view->err true;
                
                
                
    $this->view->render('Search/Index');
        }
    }
    ?>
    I had to remove the sql or submitting this post would error.

    And the errors I get on the next page.

    PHP Code:
    <b>Notice</b>:  Undefined indexattrib1 in <b>C:\xampp\htdocs\us\sc\controllers\Search.php</bon line <b>14</b><br />
    <
    br />
    <
    b>Notice</b>:  Undefined indexattrib2 in <b>C:\xampp\htdocs\us\sc\controllers\Search.php</bon line <b>16</b><br />
    <
    br />
    <
    b>Notice</b>:  Undefined indexattrib3 in <b>C:\xampp\htdocs\us\sc\controllers\Search.php</bon line <b>17</b><br />
    <
    br />
    <
    b>Notice</b>:  Undefined indexattrib4 in <b>C:\xampp\htdocs\us\sc\controllers\Search.php</bon line <b>18</b><br />
    <
    br />
    <
    b>Notice</b>:  Undefined indexattrib5 in <b>C:\xampp\htdocs\us\sc\controllers\Search.php</bon line <b>19</b><br />
    <
    br />
    <
    b>Notice</b>:  Undefined indexattrib6 in <b>C:\xampp\htdocs\us\sc\controllers\Search.php</bon line <b>20</b><br />
    <
    br />
    <
    b>Notice</b>:  Undefined indexattrib7 in <b>C:\xampp\htdocs\us\sc\controllers\Search.php</bon line <b>21</b><br />
    <
    br />
    <
    b>Notice</b>:  Undefined indexattrib8 in <b>C:\xampp\htdocs\us\sc\controllers\Search.php</bon line <b>22</b><br />
    <
    br />
    <
    b>Notice</b>:  Undefined indexlist_1 in <b>C:\xampp\htdocs\us\sc\controllers\Search.php</bon line <b>23</b><br />
    <
    br />
    <
    b>Notice</b>:  Undefined indexlist_2 in <b>C:\xampp\htdocs\us\sc\controllers\Search.php</bon line <b>24</b><br />
    <
    br />
    <
    b>Notice</b>:  Undefined indexlist_3 in <b>C:\xampp\htdocs\us\sc\controllers\Search.php</bon line <b>25</b><br />
    <
    br />
    <
    b>Notice</b>:  Undefined indexlist_4 in <b>C:\xampp\htdocs\us\sc\controllers\Search.php</bon line <b>26</b><br />
    <
    br />
    <
    b>Notice</b>:  Undefined indexlist_5 in <b>C:\xampp\htdocs\us\sc\controllers\Search.php</bon line <b>27</b><br />
    <
    br />
    <
    b>Notice</b>:  Undefined indexlist_6 in <b>C:\xampp\htdocs\us\sc\controllers\Search.php</bon line <b>28</b><br />
    <
    br />
    <
    b>Notice</b>:  Undefined indexlist_7 in <b>C:\xampp\htdocs\us\sc\controllers\Search.php</bon line <b>29</b><br />
    <
    br />
    <
    b>Notice</b>:  Undefined indexlist_8 in <b>C:\xampp\htdocs\us\sc\controllers\Search.php</bon line <b>30</b><br />
    <
    br />
    <
    b>Notice</b>:  Undefined indexquality in <b>C:\xampp\htdocs\us\sc\controllers\Search.php</bon line <b>31</b><br />
    <
    br />
    <
    b>Notice</b>:  Undefined indextype in <b>C:\xampp\htdocs\us\sc\controllers\Search.php</bon line <b>32</b><br />
    <
    br />
    <
    b>Notice</b>:  Undefined indexsub in <b>C:\xampp\htdocs\us\sc\controllers\Search.php</bon line <b>33</b><br /> 
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,245
    Rep Power
    9400
    Could just pass the variables via GET instead of POST. Technically speaking you should anyways: POST is about modifying data, and using GET opens you up to caching.

IMN logo majestic logo threadwatch logo seochat tools logo