Page 1 of 2

Download page creater

Posted: Sat Nov 22, 2003 11:26 am
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

Posted: Sat Nov 22, 2003 12:42 pm
by vigge89
do you want to use flatfile, or do u want to generate a HTML file?

reply

Posted: Sat Nov 22, 2003 12:45 pm
by dull1554
I want to generate a html file.

Posted: Sat Nov 22, 2003 12:58 pm
by vigge89
should the HTML file be the same as the script, or should they be separated, ie add_dl.php & download.html?

Posted: Sat Nov 22, 2003 1:01 pm
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.

Posted: Sat Nov 22, 2003 1:12 pm
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.

Posted: Sat Nov 22, 2003 1:19 pm
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.

Posted: Sat Nov 22, 2003 1:24 pm
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

Posted: Sat Nov 22, 2003 1:33 pm
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

Posted: Sat Nov 22, 2003 1:37 pm
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

Posted: Sat Nov 22, 2003 1:45 pm
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

Posted: Sat Nov 22, 2003 2:05 pm
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:

reply

Posted: Sun Nov 23, 2003 8:02 pm
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>

Posted: Sun Nov 23, 2003 8:04 pm
by dull1554
i just dont have a clue whats wrong with it/don't have a clue as to how to fix it

Posted: Sun Nov 23, 2003 8:14 pm
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)