Download page creater

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

User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Download page creater

Post by dull1554 »

Hello, I tried to write a script that would take information that i enter into it and write that info to a download page, I'm kinda new to this and what i tried failed horriably, i wanted to be able to enter 1) the name of the download 2) the url of the download(this would be displayed as a download link) 3) download information. i wanted the script to toss all of the info into a table on page called download.html, and i can't have a database backend, any input would be greatly appreciated, thanks
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

do you want to use flatfile, or do u want to generate a HTML file?
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

reply

Post by dull1554 »

I want to generate a html file.
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

should the HTML file be the same as the script, or should they be separated, ie add_dl.php & download.html?
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

i want it so i can have add_dll.php and download.html, that way i can have my site call the download.html file and the user wont see any of the add download stuff, then i'll put the add_dl.php in my admin section and password protect it.
maniac9
Forum Commoner
Posts: 55
Joined: Fri Aug 01, 2003 12:27 am
Location: Arkansas, USA
Contact:

Post by maniac9 »

couldn't you just make one page, and have that page create a blank page or a page with downloads depending on whether a password supplied? maybe i'm not understanding you, but that would be the way I would do it.
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

the only reason i want to use php on this section of my site is for my ease, all i want add_dl.php to do is just to append downloads.html with whatever download i wish to add to it, its just so i dont have to edit the html file directly, i want to be able to do it all over the web, i want to add add_dl.php to my site's admin section like its a module.
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

although i guess i could have 1 php file that was loaded as say ... download.php, have this file display all available downloads, and then have a form at the bottom of the page to enter a administrative password, then have it take you to another form in that script to append another download to the php file, but keeping in mind that i don't have a database at my disposal to store download information in
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

If a database isn't available, most PHP users will go with flat files (plain old text files). You store information in the text files then use PHP to open the text files, read through them and output it however you want. Heres a simple tutorial:

http://www.devarticles.com/art/1/292
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

you dont want both in the same page?
you don't need to, just use something like download.php for viewing, and then you can use download.php?op=add if you want to add something
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

yeah vigge89 i think that if download.php was for viewing, and you would add a file by download.php?op=add, it would be good if add was password protected
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

if you could try too go as far as you can with the script, the template for the viewing of the downloads, and the form etc, and then show us what you got, you'll get help faster :wink:
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

reply

Post by dull1554 »

createdownload.php

PHP:
?php
echo "<form action='createdownload.php' method='post'>";
echo "Name of download: <input type='text' name='name'>";
echo "<br>";
echo "Link: <input type='text' name='link'>";
echo "<br>";
echo "Information: <br> <textarea name="info" rows='5' cols='30' wrap="soft">Enter your download description here.</textarea>";
echo "<input type='submit' value='submit'>";

if($submit) {
if($name == "")
$message = "Please input a name";
else if($link == "")
$message = "Please input a link";
else if($info == "")
$message = "Please describe the download";

if($message)
echo($message);
else {
$fp = fopen("download.txt", "w+");
$insertcode = "<table><tr><td width='200' border='1'>$name - <a href='$link'>download</a></td></tr><tr><td width='200' border='1'>$info</td></tr></table>";
fwrite($fp,"$insertcode");
fclose($fp);
}
}
?


download.txt contains nothing when uploaded.

Then have your html document:

Code:

html>
body>
h3>Downloads</h3>
p>
!--#include virtual="download.txt"-->
/body>
/html>
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

i just dont have a clue whats wrong with it/don't have a clue as to how to fix it
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

createdownload.php

Code: Select all

<?php
echo "<form action='createdownload.php' method='post'>";
echo "Name of download: <input type='text' name='name'>";
echo "<br>";
echo "Link: <input type='text' name='link'>";
echo "<br>";
echo "Information: <br> <textarea name="info" rows='5' cols='30' wrap="soft">Enter your download description here.</textarea>";
echo "<input type='submit' value='submit'>";

if($submit) &#123;
if($name == "")
  $message = "Please input a name";
else if($link == "")
  $message = "Please input a link";
else if($info == "")
  $message = "Please describe the download";

if($message)
  echo($message);
else &#123;
$fp = fopen("download.txt", "w+");
$insertcode = "<table><tr><td width='200' border='1'>$name - <a href='$link'>download</a></td></tr><tr><td width='200' border='1'>$info</td></tr></table>";
fwrite($fp,"$insertcode");
fclose($fp);
  &#125;
&#125;
?>
(new to this whole forum thing)
Post Reply