Letting visitors use "self-submission" for links

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
thefluffyshrimp
Forum Newbie
Posts: 4
Joined: Mon Jul 04, 2005 7:52 pm

Letting visitors use "self-submission" for links

Post by thefluffyshrimp »

I'm somewhat new to php and I was wondering if someone more experienced would be kind enough to walk me through this process. :)

I am creating a website that will allow my visitors to submit "fan fiction." However, not having the time (or interest) to manually upload all submitted fanfiction over the years, I have decided to get my visitors to submit their work to a third party, such as "fanfiction.net" and then have them submit the link to their fan fiction to my website, saving me time and space.

But I would like to take it one step further. Because I would like to have my visitors submit their fanfiction under certain topics (such as "genre"), it would become a hassle to constantly have to organize the submitted links. Therefore, I would like to develop a process where my visitors can submit fanfiction to my website by themselves, and have the fictions organized under certain selected topics automatically.

For the ideal form, I would like a visitor looking to submit a link to their fanfiction (hosted on a third party) to copy and paste their link into a field, type the title, chosen author name, and short description of the story in three other fields, and then select one (or two) categories to place it under from a drop-down menu. Then they could submit the link and have that link automatically placed under a particular category (reached by link) on the webpage.

(Example fields)

URL of fanfiction: ______

Title of fanfiction: ______

Author name: ______

Short Description of story: ______

[Chose from a list of categories] (such as genre)

Then visitors browsing the fanfiction, could select from a list of categories and find all links to fanfiction submitted in that category. I would like the layout of the submitted link to be viewed like this:
_______

"Title of Story, which links to story from third party" by "author name" in "Category name, which links to category."
Description: "Short Description of story"
_______

(or)

"The Raven" by Edgar Allen Poe in Horror
Description: A raven visits a man....
_______

And that's basically it. Does anyone know of any borrowed code I could use that could accomplish this, or some borrowed code I could use and play with to make it do this? Or, if anyone would be kind enough to walk me through it or send me the basic code for it, I could accomplish the rest (customizing it and such).

Thank you so much! :D :D
User avatar
IceMetalPunk
Forum Commoner
Posts: 71
Joined: Thu Jul 07, 2005 11:45 am

Post by IceMetalPunk »

If I understand you right, the users submit the URL to download their fan fiction, right? If so, I'd use this:

Code: Select all

<?php
for ($i=1; file_exists("fanfict".$i.".txt"); $i+=1) {}
$f=fopen("fanfict".$i.".txt","w");
fwrite($author."\r\n".$title."\r\n".$url."\r\n".$cat."\r\n".$desc);
fclose($f);
?>
That will write the information to a file called fanfict1.txt, fanfict2.txt, fanfict3.txt, etc. so there can be an infinate number of submissions (as long as you have enough storage space on your server). If you do not use a Windows server, change all the

Code: Select all

"\r\n"
to just "\n".

That's how to write it. Now, to read it back, do this:

Code: Select all

<?php
for ($i=1; file_exists("fanfict".$i.".txt"); $i+=1) {
$f=fopen("fanfict".$i.".txt","r");
$all=fread($f,filesize("fanfict".$i.".txt"));
$all=explode("\r\n",$all);
$author=$all[0];
$title=$all[1];
$url=$all[2];
$cat=$all[3];
$desc=$all[4];
echo "<u><b><a href='".$url."'>".$title." By ".$author."</a> in ".$cat."</u></b><br>".$desc."<br><br>";
fclose($f);
}
?>
That will write every submitted story to the page, where the title/author is underlined and a link to the URL supplied for that story.

-IMP ;) :)
thefluffyshrimp
Forum Newbie
Posts: 4
Joined: Mon Jul 04, 2005 7:52 pm

Post by thefluffyshrimp »

Oh, thank you so very much for your help! :D :D

But what I'm looking for more is for the visitors who want to submit their fanfiction, to just submit the link only (from a third party). I wanted the visitors to submit links to their fanfiction from other websites. That way, they can host their fanfiction anywhere, or have had it already submitted somewhere else, and just submit a link to it. This should save me space on my server. ;)

So basically, I would just like the visitors to submit the url to their fanfiction without downloading the actual fanfiction from that page (if that's what you meant - forgive me if I misunderstood :oops:). They would just submit the name of their fiction, their author name, a short description of it, and submit the link to it so visitors can get to it.

The real trick is to get the submissions to organize themselves based on category. After a visitor selects a category from a drop-down menu, I wanted the link (and info) submitted of that fanfiction to be categorized by links to those different categories (I'll give a little visual below ^^).

That way, visitors looking for stories based on, let's say, a particular genre, could search my list of genres and click on a link to which genre they want to read from. Then, all links to fanfictions submitted under that category would appear on a new page. ^^

So if someone submitted a fanfiction under "Horror," it would appear on my fanfiction section like so:

Adventure

Comedy

Horror ( < that submitted fanfiction would appear on a list of fiction in this category, when the visitor clicked on this link).

Drama

Romance

Etc.

I apologize if I'm making this more confusing than it needs to be.
:oops: If you need me to explain it better, just let me know. ^^

Again, thank you very much for helping me! :D
Post Reply