Download page creater
Moderator: General Moderators
- 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
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
- dull1554
- Forum Regular
- Posts: 680
- Joined: Sat Nov 22, 2003 11:26 am
- Location: 42:21:35.359N, 76:02:20.688W
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.
- dull1554
- Forum Regular
- Posts: 680
- Joined: Sat Nov 22, 2003 11:26 am
- Location: 42:21:35.359N, 76:02:20.688W
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
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
http://www.devarticles.com/art/1/292
- dull1554
- Forum Regular
- Posts: 680
- Joined: Sat Nov 22, 2003 11:26 am
- Location: 42:21:35.359N, 76:02:20.688W
reply
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>
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>
- dull1554
- Forum Regular
- Posts: 680
- Joined: Sat Nov 22, 2003 11:26 am
- Location: 42:21:35.359N, 76:02:20.688W
createdownload.php
(new to this whole forum thing)
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) {
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);
}
}
?>