Current location: Hot Scripts Forums » Programming Languages » PHP » PHP File handling


PHP File handling

Reply
  #1 (permalink)  
Old 12-02-11, 08:57 PM
Nicky Nicky is offline
New Member
 
Join Date: Dec 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rolleyes PHP File handling

I am new to php. Need your help Please......
following are my requirements in short.

1. I need to get data from a text file.
2. When the user select one item, I need it to be dispaly on a seperate file. (like you have selected
"name")
3. When everytime I update the list on my text file I need them to be updated on other file with the
check box too.
4. If user select more than one item, I need to display error message. ("Please select one")
something.
5. If user select none again I need error message ("something")
6. When user correctly select only one item, then another message. ("something) and it
should write to other file

I wrote following codes and still I can not get this correct. Can someone please help me.


PHP Code:



 <form action ="processfile.php" method ="POST">

            <?php
            
// I used following code to get the array from  "mylist.txt" file. When I run the file, it displays all the list names with a check box.(that's what I wanted) but,  
            // When the user tick one box and submit the form I need user's selected list name appear on my "processfile.php"
            // But instead, I am getting " You have Selected array. 1 name selected.

                     
           
$listName file("mylist.txt");

            foreach (
$listName as $name) {
                print 
"<input type=\"checkbox\" name=\"listName[]\" value=\"$name\" />";
                print 
"$name <br/>";
            }
            
?>
            
            <input type="submit" name="submit" value="submit"/>
        </form>

PHP Code:

// On on my "processfile.php" I wrote following codes. 

        
        
    <?php
        
        
print "You have Selected .{$_POST['listName']}<br/>";

        print 
"<br/>" count($_POST['listName']) . " name selected.<br/>";
        
        
$listfile fopen("userchoice.txt"'w') or die("Can not open the file");
        
fwrite($listfile$_POST['listName']);
        
fclose($listfile);
Please help me..
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
php file upload isn't working mybluehair1 PHP 5 08-11-10 03:10 AM
[SOLVED] it works on localhost but not on hosting account? myslowquietlife PHP 42 12-19-08 09:31 AM
PHP File Upload Basics phpboy6 PHP 4 05-02-08 05:55 PM
Saving php generated file as html file GS300 PHP 0 12-29-04 03:34 AM


All times are GMT -5. The time now is 08:58 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.