| | |
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 |
ajax apache api array basics beginner binary bounce broken cakephp checkbox class cms code codingproblem combobox cron curl database date display dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration interactive ip java javascript joomla js limit link login mail menu mlm mobile multiple mysql nodes oop outofmemmory paging parse paypal pdf php problem procedure query radio ram random recursion regex remote return script search server sessions smash sms soap source space sql syntax system table tutorial up-to-date update upload url validation validator variable video web webapplications websitecontactform xml youtube





