Page 1 of 1

Writing to a file

Posted: Tue Apr 26, 2005 10:31 am
by rayner75
Hello, on my site i have a feedback page feedback.htm
and the forms action points to reply.php where i write out what the person has put.
I can also get it to write to a text file, but it goes along in a line,
i am not sure how to get it to write to a text file line by line
Example:
Name: Andy
Age: -20
at the Momement i am getting

Name: Andy Age: - 20 ect....

Here is the code in my reply.php

Code: Select all

<?php
		$name = $_POST&#1111;'name'];
		$age = $_POST&#1111;'age'];
		$member = $_POST&#1111;'member'];
		$reserve = $_POST&#1111;'reserve'];
		$useful = $_POST&#1111;'useful'];
		$information = $_POST&#1111;'information'];
		$comments = $_POST&#1111;'comments'];
		
		echo &quote;<b>Name: </b>&quote;.$name; ?><br><?
		echo &quote;<b>Age: </b>&quote;.$age; ?><br><?
		echo &quote;<b>Current Member? </b>&quote;.$member; ?><br><?
		echo &quote;<b>Have you ever reserved anything? </b>&quote;.$reserve; ?><br><?
		echo &quote;<b>Do you find this site useful? </b>&quote;.$useful; ?><br><?
		echo &quote;<b>Do you think the information is up-to-date? </b>&quote;.$information; ?><br><?
		echo &quote;<b>Any Comments? </b>&quote;.$comments; 
		
		$SEPARATOR = &quote;::&quote;;
      
      	$filename = 'feedback.txt';
		
      
      	$details = &quote;Name: $name&quote;.$SEPARATOR.
       	           &quote;Age: $age&quote;.$SEPARATOR.
		   		   &quote;Current Member? $member&quote;.$SEPARATOR.
				   &quote;Reserved Anything? $reserve&quote;.$SEPARATOR.
				   &quote;Site Useful? $useful&quote;.$SEPARATOR.
				   &quote;Up-to-date Infor? $information&quote;.$SEPARATOR.
				   &quote;Comments? $comments&quote;.$SEPARATOR;
                         
      
       $file = fopen($filename,&quote;a&quote;);
       fputs ($file, $details);
       fclose($file);
?>
Thanks for any help
Andy

Posted: Tue Apr 26, 2005 11:09 am
by oceglok
Maybe

Code: Select all

$SEPARATOR = "::\r\n";
Hope, this helps
oceglok

Posted: Tue Apr 26, 2005 11:27 am
by rayner75
Thanks that helped :)