How to do postback in html form when we use PHP ?

Discussion in 'PHP' started by salsan, Jul 28, 2010.

  1. #1
    How to do postback in html form when we use PHP ?

    The postback method should be free from XSS vulnerability.


    Thanks in advance...
     
    salsan, Jul 28, 2010 IP
  2. Deacalion

    Deacalion Peon

    Messages:
    438
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Not sure what you want to do. You can output HTML from PHP in several ways:

    
    <?php
        echo <<<HTML
    <html>
        <head>
            <title>Web Page</title>
        </head>
    
        <body>
        Your web page
        </body>
    
    </html>
    HTML;
    ?>
    
    PHP:
    Or beak out of PHP:
    
    <?php
        // PHP here...
    ?>
    <html>
        <head>
            <title>Web Page</title>
        </head>
    
        <body>
        Your web page
        </body>
    
    </html>
    <?php
        // PHP here...
    ?>
    
    PHP:
     
    Deacalion, Jul 28, 2010 IP
  3. salsan

    salsan Active Member

    Messages:
    190
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    73
    #3
    This is not what i meant.

    I will explain it.

    I have a html form
    When we submit the form, it will validate values from server side.
    And if any validation errors are there, it will come back to the html form with values they filled.

    I know this method - <input type="text" name="txtName" value="<?php echo $_REQUEST['txtName']; ?>" />

    but this method is having high XSS vulnerability risk.

    I am looking for another method if any........
     
    salsan, Jul 29, 2010 IP
  4. Johnta

    Johnta Peon

    Messages:
    101
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You can use if isset function before printing the variable
     
    Johnta, Jul 29, 2010 IP
  5. andymoo

    andymoo Peon

    Messages:
    169
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    And clean all user input before you even consider doing anything with it like showing it to the browsers
     
    andymoo, Jul 29, 2010 IP