| | |
Script to add url to text file
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jan 2009
Posts: 4
Reputation:
Solved Threads: 0
I am looking for a php code to add a url to a text file like this
1- user adds url to a text box
2- user adds site name
3- user hits submit button
The url that was entered in to the text box is then added to a .txt file along with the site name and is phased threw as a link so when it is output it looks like this: <a href="http://sample.com/">Sample</a>.
I will then use an <? includes ("file.txt"); ?> to pull the txt file to the page i want it to.
The link then should look like Sample and is clickable.
Is this possible?
1- user adds url to a text box
2- user adds site name
3- user hits submit button
The url that was entered in to the text box is then added to a .txt file along with the site name and is phased threw as a link so when it is output it looks like this: <a href="http://sample.com/">Sample</a>.
I will then use an <? includes ("file.txt"); ?> to pull the txt file to the page i want it to.
The link then should look like Sample and is clickable.
Is this possible?
•
•
•
•
Originally Posted by wxflint
Is this possible?
It wouldn't take much research either. There are plenty of tutorials online for how to write to a file using PHP, including a good example on php.net.
•
•
•
•
Originally Posted by PHP.net
php Syntax (Toggle Plain Text)
<?php $filename = 'test.txt'; $somecontent = "Add this to the file\n"; // Let's make sure the file exists and is writable first. if (is_writable($filename)) { // In our example we're opening $filename in append mode. // The file pointer is at the bottom of the file hence // that's where $somecontent will go when we fwrite() it. if (!$handle = fopen($filename, 'a')) { echo "Cannot open file ($filename)"; exit; } // Write $somecontent to our opened file. if (fwrite($handle, $somecontent) === FALSE) { echo "Cannot write to file ($filename)"; exit; } echo "Success, wrote ($somecontent) to file ($filename)"; fclose($handle); } else { echo "The file $filename is not writable"; } ?>
AJAX is not a programming language, scripting language or any other sort of language.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.
![]() |
Similar Threads
- check text file for email address... need help (PHP)
- need help how to produce a txt file after email being sent in ASP (ASP)
- how to update a field in mysql with txt file. (MySQL)
- Need help with php mailing list/redirect (PHP)
- Please help to modify this perl script. I need to add more urls (Perl)
Other Threads in the PHP Forum
- Previous Thread: Php Gallery
- Next Thread: Calling PHP function Onchange on Javascript
| Thread Tools | Search this Thread |
.htaccess ajax apache api array beginner binary broken buttons cakephp checkbox class cms code cron curl database date directory display download dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla limit link login loop mail mediawiki menu mlm mod_rewrite multiple mysql number oop paypal pdf php phpincludeissue phpmyadmin problem query radio random recursion regex remote script search server sessions sms soap source sp space speed sql subdomain syntax system table tag tutorial update upload url validation validator variable vbulletin video web websphere white xml youtube





