nvidia Posted December 22, 2006 Share Posted December 22, 2006 Hi everybody, i have created a form whereby people select who they want to do a bush tuker trial as seen on tv. They select via radio buttons and they press submit. After submitting the votes they are supposed to be stored in a txt file. When they press submit, a page should be displayed showing as a percentage how many people have voted. Right now i am able to write to the file with the votes. My question is, after submitting the second vote or third etc, what is the easiest and quickestway of adding this to the next line? Because everytime i add the next vote, i c partial name of first vote and patial second vote on the same line. I tried to create a variable to hold a new line character and did some modifcations but no luck. Please help :-[. Simplest and easiest way if possible guys ;)[code]form1.html file:html> <head> <title> COURSEWORK 2</title> </head> <body> <center> <form method="post" action="handler1.php"> <table border cellpading = "2"> <tr> <td> Please select one of the contestants to do a bush tutrial: </td> </tr> <tr> <td> Mr.X <input type="radio" name="select" value="Mr.X " CHECKED> <br /> </td> </tr> <td> Tom Cruis <input type="radio" name="select" value="Tom Cruis " ><br /> </td> </tr> </table> <input type=submit value="Press me!" /> </form> </center> </body></html>[hr]handler1.php file <html> <head> <title> Page 2 </title> </head><body><?php session_start(); $selection = $_POST['select'] ;// store location of file in variable$filename = "/home/eland/u1/kbccs/w1009048/public_html/Internet_Pg/C2/C2.txt"; $counter = 0; $newline = "\n"; $fp = fopen($filename,'r+'); // r+ is open for reading + writing $write = fwrite($fp,$selection);// $writeln = fwrite($fp,$newline); //$contents = fread( $fp,filesize($filename) ); fclose($fp);?> You selected <? echo $selection ?><!-- in the C2.txt <? echo $write ?> --><!-- The contents of the file C2.txt is : <? echo $contents ?>--></body></html>[/code]I suggest you copy the code onto your computer to work with. :D Link to comment https://forums.phpfreaks.com/topic/31621-php-form-help/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.