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

    Join Date
    Apr 2013
    Posts
    40
    Rep Power
    2

    Pagination and search function together


    Good afternoon friends at DevShed

    I have a script that allows a user to type in a search term and the page will refresh with relevant search terms

    My pagination script uses $_GET to display information and so does my search script.

    How do I display both the page=X and search=X on the same page?

    Whenever I click the NEXT button on my site, index.php?search= turns into index.php?page=

    Any suggestions for adding both GET statements to the URL?

    Is pagination compatible with PHP search function?

    Thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Dec 2004
    Posts
    3,027
    Rep Power
    377
    you need to "manually" append that to the end of the page..

    if (isset($_GET['search'])) {
    $append_url .= search=$_GET['search']
    }

    Comments on this post

    • Jacques1 disagrees : Inserting raw $_GET values? C'mon...
  4. #3
  5. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Nooooo

    You've just made his/her code vulnerable to pretty much any attack known to man. URL input must be encoded, and then the whole URL string should be escaped.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Dec 2004
    Posts
    3,027
    Rep Power
    377
    sorry, unlike others I do not want to repeat the same stuff like others do all the time i.e. security using PDO etc etc. i told him the logic of how he should go about it! it wasnt meant to be a complete answer, just show him how to do it
  8. #5
  9. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    When you don't wanna post proper PHP code, then don't post PHP code at all. After more than 2000 posts, you should know that anything looking like a solution will be copied and pasted and that a lot of people have never heard of escaping.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Dec 2004
    Posts
    3,027
    Rep Power
    377
    Originally Posted by Jacques1
    When you don't wanna post proper PHP code, then don't post PHP code at all. After more than 2000 posts, you should know that anything looking like a solution will be copied and pasted and that a lot of people have never heard of escaping.
    sorry you are right, i'll bear that in mind.. thanks

IMN logo majestic logo threadwatch logo seochat tools logo