form data being sent to file

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
php-forum Active User
php-forum Active User
Posts: 388
Joined: Thu Mar 15, 2012 3:59 pm

Wed Jun 19, 2013 2:56 pm


The array $_REQUEST will contain all your form field names and values. You can output it with print_r() or you could process each field with some code like this:

Code: Select all

    $sOut= ''; // Result string
    foreach ($_REQUEST as $sKey => $sValue) {
        // Add each form field to $sOut
        $sOut .= $sKey .'=' . $sValue . "\n";    
    //print str_replace("\n", '<br>', $sOut);
    // Output the result string to a file
    file_put_contents('/tmp/file.txt', $sOut);
Hope that helps

Post Reply