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

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; 
?>





Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.