Secure Method $_POST

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tbebest
    New Member
    • Dec 2010
    • 10

    Secure Method $_POST

    Hi all, What should i do for secure $_post;
    I used to define a var :
    Code:
    $comment=$_POST['comment'];
  • AutumnsDecay
    New Member
    • Mar 2008
    • 170

    #2
    Hey tbebest,

    I'm not sure I quite understand the question.

    There are two methods to do send information between pages from a form: $_GET and $_POST.

    GET will put the contents of the form element into the web-browser address bar (ie. www.yoursite.com/search.php?term=Foo).

    POST sends the data from the page through the server and is able to be called on the proceeding pages without it being broadcast through the address bar.

    You could try using PHPs md5 hashing ability to send the information between pages. Additionally you could also look into SSL certificates, which allow for https:// connections, which are generally secured by at least 128-bit encryption.

    Comment

    • tbebest
      New Member
      • Dec 2010
      • 10

      #3
      Hi AutumnsDecay,
      My Queston is about cross site scripting and SQL injection, so on XSS attacks.
      regards N TNX.

      Comment

      • AutumnsDecay
        New Member
        • Mar 2008
        • 170

        #4
        The best way around SQL injection is to never run an SQL statement without verifying the source of the user.

        If the user starts at your index.php page, set a $_SESSION variable called 'start' or something. On each page afterwards, do $session_start so it holds onto the session info.

        When you finally go to do your SQL query, run an if statement to make sure they started from where they typically would have, which would be the index.php page.

        Code:
        if ((!$_SESSION['start']) || ($_SESSION['start']=="") || ($_SESSION['start']==null)){
           echo 'You do not have permission to perform this action';
        }
        
        else {
            MYSQL QUERY
        }
        Something like that is decent.

        If you're specifically worried about your form elements and how they're broadcast, look into SSL.

        Comment

        • JKing
          Recognized Expert Top Contributor
          • Jun 2007
          • 1206

          #5
          Always use mysql_real_esca pe_string() when passing any variable to a mysql query. It will escape any characters used by mysql, preventing the user from executing an SQL injection.

          Comment

          • tbebest
            New Member
            • Dec 2010
            • 10

            #6
            Hi AutumnsDecay and JKing, your answers is so good;
            more efficient answer for me is both,TNX.

            Comment

            Working...