Jump to content

writing to a text document


ball420

Recommended Posts

This code snippet assumes the input is in a form:

<?php
$mode = file_exists('user_input.txt')?'a':'w'; // append if file exists otherwise create it
$fp = fopen('user_input.txt',$mode);  // open file
fwrite($fp,print_r($_POST,true)."\r\n");  // dump the contents of the $_POST array to the file
fclose($fp);
?>

 

Ken

Link to comment
Share on other sites

it's not even creating it i'll show you how i have put it in my code. Mabey i'm not formating it right

 

<?php


if(isset($_POST['submit'])) {

$errmsg  = ''; // error message



$nextstep = "nextstep.php";
   

$song1 = $_POST['song1'];
$song2 = $_POST['song2'];
$song3 = $_POST['song3'];
$song4 = $_POST['song4'];
$song5 = $_POST['song5'];
$song6 = $_POST['song6'];
$song7 = $_POST['song7'];
$song8 = $_POST['song8'];
$song9 = $_POST['song9'];
$song10 = $_POST['song10'];


$body = "

$song1 /n
$song2 /n
$song3 /n
$song4 /n
$song5 /n
$song6 /n
$song7 /n
$song8 /n
$song9 /n
$song10 /n


" ;

  }
  
  
  

$mode = file_exists('user_input.txt')?'a':'w'; // append if file exists otherwise create it
$fp = fopen('user_input.txt',$mode);  // open file
fwrite($fp,print_r($_POST,true)."\r\n");  // dump the contents of the $_POST array to the file
fclose($fp);

        
header('Location: nextstep.php');



exit; 
?>





Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.