Connect with Facebook Lost Password?


Go Back   CodeCall Programming Forum > Software Development > Tutorials > PHP Tutorials

PHP Tutorials PHP Tutorials

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-03-2007, 05:40 AM
Jaan's Avatar   
Moderator
 
Join Date: Dec 2006
Location: Estonia
Age: 18
Posts: 1,518
Blog Entries: 4
Rep Power: 24
Jaan is just really niceJaan is just really niceJaan is just really niceJaan is just really niceJaan is just really nice
Send a message via MSN to Jaan
Default Create files with php

Creating files with php is very simple. So.. let's start.

PHP Code:
<?php

// This function shows your form
function form(){

echo 
"<form action='?act=create' method='post'>"
    
."Filename: <input type='text' name='filename' size='30'><br>"
    
."<textarea cols='50' rows='10' name='content'></textarea><br>"
    
."<input type='submit' value='Create'>"
    
."</form>";

}

// This function will create your file
function create(){

// Gather info into variables from our form
$filename $_REQUEST['filename'];
$content $_REQUEST['content'];

// Now let's create our file
$open fopen($filename"a"); // Now this file is ready for overwriting
fwrite($open$content); // This will write your text what was in textarea into your file
fclose($open); // Closes your file
echo "File is created <a href='$filename'>Preview</a>";

}

switch(
$act){

default;
form();
break;

case 
"create";
create();
break;

}

?>
I hope it helped..

Regards Jaan

Last edited by Jaan; 03-02-2008 at 05:18 AM..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-01-2008, 04:05 PM
Whitey's Avatar   
Programming Professional
 
Join Date: Feb 2008
Location: Loveland, Colorado
Posts: 236
Rep Power: 9
Whitey has a spectacular aura aboutWhitey has a spectacular aura aboutWhitey has a spectacular aura about
Send a message via AIM to Whitey Send a message via MSN to Whitey Send a message via Skype™ to Whitey
Default

Doesn't work..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-01-2008, 06:21 PM
Jaan's Avatar   
Moderator
 
Join Date: Dec 2006
Location: Estonia
Age: 18
Posts: 1,518
Blog Entries: 4
Rep Power: 24
Jaan is just really niceJaan is just really niceJaan is just really niceJaan is just really niceJaan is just really nice
Send a message via MSN to Jaan
Default

yes it works
i always check my tutorials before posting them here..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-01-2008, 08:01 PM
John's Avatar   
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 5,306
Blog Entries: 24
Rep Power: 20
John is just really niceJohn is just really niceJohn is just really niceJohn is just really niceJohn is just really nice
Send a message via AIM to John Send a message via MSN to John
Default

Quote:
Originally Posted by Whitey View Post
Doesn't work..
You're right, the code appends the file to a directory calls "files." If that folder doesn't exist, it wont work. If it does exist the file will be created, but the link won't work because it is isn't linked to the files directory.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 03-02-2008, 05:12 AM
Jaan's Avatar   
Moderator
 
Join Date: Dec 2006
Location: Estonia
Age: 18
Posts: 1,518
Blog Entries: 4
Rep Power: 24
Jaan is just really niceJaan is just really niceJaan is just really niceJaan is just really niceJaan is just really nice
Send a message via MSN to Jaan
Default

well.. this is VERY wierd.. because when I create my tutorials or just scritps then i always check do they work or not.. but i'll check it..and fix something
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 03-02-2008, 05:18 AM
Jaan's Avatar   
Moderator
 
Join Date: Dec 2006
Location: Estonia
Age: 18
Posts: 1,518
Blog Entries: 4
Rep Power: 24
Jaan is just really niceJaan is just really niceJaan is just really niceJaan is just really niceJaan is just really nice
Send a message via MSN to Jaan
Default

Anyway.. now it works 100% and before it worked also..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 03-03-2008, 09:12 AM
lucky-girl's Avatar   
Newbie
 
Join Date: Dec 2007
Age: 24
Posts: 27
Rep Power: 0
lucky-girl is an unknown quantity at this point
Default

nice and easy
question
action='?act=create'
what is (?act) means?
sorry, i know its stupid question
thanks (flower)
__________________
begginer programmer needs the help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 03-03-2008, 10:28 AM
Jaan's Avatar   
Moderator
 
Join Date: Dec 2006
Location: Estonia
Age: 18
Posts: 1,518
Blog Entries: 4
Rep Power: 24
Jaan is just really niceJaan is just really niceJaan is just really niceJaan is just really niceJaan is just really nice
Send a message via MSN to Jaan
Default

hmm..
it's like.. main command and and create is a subcommand..
you can change this act to what ever your like..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 03-08-2008, 08:09 AM
Newbie
 
Join Date: Aug 2007
Posts: 11
Rep Power: 0
mittalmak is an unknown quantity at this point
Default Re: Create files with php

tha code dose not work's
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 03-08-2008, 10:56 AM
Jaan's Avatar   
Moderator
 
Join Date: Dec 2006
Location: Estonia
Age: 18
Posts: 1,518
Blog Entries: 4
Rep Power: 24
Jaan is just really niceJaan is just really niceJaan is just really niceJaan is just really niceJaan is just really nice
Send a message via MSN to Jaan
Default Re: Create files with php

yes it works..
well for me...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP 4 end of life announcement Jordan News 4 08-30-2007 09:55 AM
Where to Put PHP Code clookid PHP Tutorials 1 01-11-2007 08:44 PM


All times are GMT -5. The time now is 09:57 PM.

Freelance Jobs

XML/XSL: Need code for Book with Chapers using XML
Create an XML file for a book of your creation, and a basic CSS file that will format it to display ...
Earn: $40.00


C++/C: Simple firework cue sequencer
What I require is a rework of a simple cue sequencer. I have a piece of hardware (an Arduino boar...
Earn: $50.00


HTML/XHTML: Menu Rework - ASCIIBin
I'm placing this in the HTML/XHTML section of the Freelance site but you are not limited to HTML. Wh...
Earn: $20.00



CodeCall Goal

Goal #1: 1,000 Blogs
Goal #2: 1,000 Wiki Pages
Goal #3: 300,000 Posts
Goal #4: 20,000 Threads
Done: 30%, 23%, 55%, 75%

Ads