Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

form data being sent to file

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

form data being sent to file

Postby maximom » Tue Jun 18, 2013 11:27 am

I have created form using php and want the information from the form to be sent to a file on my website.

Can anyone please tell me the coding to do this.

thanks
maximom
New php-forum User
New php-forum User
 
Posts: 1
Joined: Tue Jun 18, 2013 11:22 am

Re: form data being sent to file

Postby landi » Wed Jun 19, 2013 2:56 pm

Hi,

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
-A
landi
New php-forum User
New php-forum User
 
Posts: 135
Joined: Thu Mar 15, 2012 3:59 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron