NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Write txt

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search
2 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 08-22-2005, 04:42 AM THREAD STARTER               #1 (permalink)
NamePros Member
 
ctechguy's Avatar
Join Date: Jun 2005
Posts: 27
ctechguy is an unknown quantity at this point
 



Write txt


I have have 3 dropdown menus and 2 text fields that i want to write the value to a txt file. The value of the objects is the same as the text above it. ex. year = year



the fromat of the text file is

Code:
year~month~day~event~link
example

Code:
2005~8~3~Ted's birthday~http://ted.piczo.com/party
ctechguy is offline  
Old 08-22-2005, 06:18 AM   #2 (permalink)
Senior Member
Join Date: May 2003
Posts: 2,187
adam_uk is a jewel in the roughadam_uk is a jewel in the roughadam_uk is a jewel in the rough
 


Breast Cancer
thats nice to know

but whats the problem?
adam_uk is offline  
Old 08-22-2005, 06:19 AM   #3 (permalink)
Senior Member
 
nasaboy007's Avatar
Join Date: Jul 2005
Location: NJ
Posts: 1,219
nasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud of
 



im assuming ur using the method="post" in ur form. so anyway, heres wut u put in the page the action links to

PHP Code:
<?
$year
=$_POST['year'];
$month=$_POST['month'];
$day=$_POST['day'];
????: NamePros.com http://www.namepros.com/programming/117545-write-txt.html
$event=$_POST['event'];
$link=$_POST['link'];
$file=fopen('file.txt','a');
fwrite($file$year "-" $month "-" $day "-" $event "-" $link "/n");
fclose($file);
?>
make sure u have a text file called file.txt. or just change the script to suit u.
get someone to look over it, the script mite have bugs i didnt go thru it and my keyboard sucks lol.
nasaboy007 is offline  
Old 08-22-2005, 08:54 AM THREAD STARTER               #4 (permalink)
NamePros Member
 
ctechguy's Avatar
Join Date: Jun 2005
Posts: 27
ctechguy is an unknown quantity at this point
 



i didn't no where to start thanks so much

is there anything i have to do to link the submit button to the php code.
ctechguy is offline  
Old 08-22-2005, 11:48 AM   #5 (permalink)
DNOA Member
Join Date: May 2004
Posts: 5,040
mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future
 


Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
<form action="php_code_that_processes_the_form_here.php" method="post">
mholt is offline  
Old 08-22-2005, 06:23 PM THREAD STARTER               #6 (permalink)
NamePros Member
 
ctechguy's Avatar
Join Date: Jun 2005
Posts: 27
ctechguy is an unknown quantity at this point
 



Is there a way if link texfield contands nothing "" to not post "~" . $link .
ctechguy is offline  
Old 08-22-2005, 06:48 PM   #7 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,074
Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute
 


Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
if the date is going to be used for something it would also be a good idea to make sure it is a valid date, for example make sure someone doesnt enter the 31st of feb.
__________________
Manage your portfolio using my new Domain Portfolio Management script.
Securing Your Domain Name From Theft
Peter is offline  
Old 08-22-2005, 09:21 PM   #8 (permalink)
Senior Member
 
nasaboy007's Avatar
Join Date: Jul 2005
Location: NJ
Posts: 1,219
nasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud of
 



well if u want to get rid of the extra ~, thats gonna make the code a lot more complicated, i think. it wud be easier to just add a "none" choice or type that in.
nasaboy007 is offline  
Old 08-23-2005, 04:57 AM THREAD STARTER               #9 (permalink)
NamePros Member
 
ctechguy's Avatar
Join Date: Jun 2005
Posts: 27
ctechguy is an unknown quantity at this point
 



if i type none in the textfield it will add the link none so when you click it, it looks for a website name none
ctechguy is offline  
Old 08-23-2005, 06:58 AM THREAD STARTER               #10 (permalink)
NamePros Member
 
ctechguy's Avatar
Join Date: Jun 2005
Posts: 27
ctechguy is an unknown quantity at this point
 



what if i disable the text field and to enable it the hit a button. What do i need for a action to enable textfield link?
ctechguy is offline  
Old 08-24-2005, 09:02 AM THREAD STARTER               #11 (permalink)
NamePros Member
 
ctechguy's Avatar
Join Date: Jun 2005
Posts: 27
ctechguy is an unknown quantity at this point
 



What does "/n" do.

Is there a way to tell it to go to next line. at the begin or end
ctechguy is offline  
Old 08-24-2005, 09:06 AM   #12 (permalink)
Senior Member
Join Date: May 2005
Location: Ontario Canada
Posts: 3,088
unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold
 


Diabetes
I think the /n goes to the new line

or try /r/n
unknowngiver is offline  
Old 08-24-2005, 03:30 PM   #13 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,074
Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute
 


Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
/r is a carriage return and /n is a new line.
__________________
Manage your portfolio using my new Domain Portfolio Management script.
Securing Your Domain Name From Theft
Peter is offline  
Old 08-24-2005, 03:48 PM   #14 (permalink)
DNOA Member
Join Date: May 2004
Posts: 5,040
mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future
 


Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
No, \r is a carriage return and \n is a new line.
mholt is offline  
Old 08-24-2005, 04:00 PM   #15 (permalink)
Eating Pie
 
iNod's Avatar
Join Date: Nov 2004
Location: Canada
Posts: 2,267
iNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud of
 


Special Olympics AIDS/HIV Cystic Fibrosis Save The Children Baby Health Cystic Fibrosis
Here is fixed code
PHP Code:
<?php
//Define the file
$file "text.txt";

//Open file
$open fopen($file"a+");

//Define what to write
if(isset($_POST['link'])) {
$txt $_POST['year'] . "-" $_POST['month'] . "-" $_POST['date'] . "-" $_POST['event'] . "-" $_POST['link'] . "\n";
}else{
$txt $_POST['year'] . "-" $_POST['month'] . "-" $_POST['date'] . "-" $_POST['event'] . "\n";
????: NamePros.com http://www.namepros.com/showthread.php?t=117545
}

//Write to file
$write fwrite($open$txt);

//Check for writing errors
if(!$write) {
echo 
"Couldn't write information to file";
}

//Close file for security
fclose($open);
?>
If you want to display what the file says

PHP Code:
<?php
//Define file
$file "file.txt";

//Open file
$open fopen($file"r");

//Read file
$read fread($filefilesize ($file));

//Parse the contents
$e explode('-'$read);
????: NamePros.com http://www.namepros.com/showthread.php?t=117545

//Print the contents
$year $e[0];
$month $e[1];
$date $e[2];
$event $e[3];
$link $e[4];

print 
"Year $year";
print 
"Month $month";
print 
"Date $date";
print 
"Event $event";
print 
"Link $link";

//Close file
fclose($open);
?>
Good Luck!
__________________
I feel old.
Last edited by iNod; 08-24-2005 at 04:10 PM.
iNod is offline  
Closed Thread


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Free txt messages (uk & us) liam_d Free Resources 0 07-04-2005 01:58 AM
Could someone at NP write a guide? Ringr Domain Newbies 1 11-27-2004 09:45 AM
10 Auctions: TXT Files e39m5 The Break Room 23 05-25-2004 01:53 PM
Write an article ...Go on! trenton Website Development 2 03-26-2004 01:57 PM

 
All times are GMT -7. The time now is 12:12 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger