You are invited to Log in or Register a free Frihost Account!

need help with a script

i'm trying to make a form where i can type in my available downloads on my website by default into a MySQL database. the database will store the name of the file, an auto-generated id and the number of times it has been downloaded. i want to use this database to offer downloads to users in the form "" and then also display the number of times the files have been downloaded. i knw how to make and connect to the database. confused about the main stuff. plz help!!!

i would also like files tht are uploaded by users to be integrated with this database so i can contain all the downloads in one section and not in a default downloads section and a one for the uploaded files
about your second part, frihost does not allow people to upload files to your site

and about your first part....
when someone types download.php?id=0, the 0 is stored in a get variable, to access this variable, do $_GET['id'].

so what you could do is something like this...

if (isset($_GET['id'])) { // checks if the variable is set
// you want to do a preg_match check to see if the id number is an integer for security purposes, but i didnt show how to do that, just make sure you do

$id = $_GET['id'];
mysql_connect(input your info here);
$sql = "SELECT * FROM <enter ur table name here> WHERE id = $id";
$result = mysql_query($sql);

if (mysql_num_rows($result) > 0) { // someone typed an id that does exist so give htem what they want
// what I like to do is store all the columns for this particular row in seperate variables, to do this, replace what i type with what you need
$column_name1 = mysql_result($result,0,"column_name1");
$column_name2 = mysql_result($result,0,"column_name2");
// etc, etc, etc
// ok, so here you want to echo out your html that you want to show, for example....
echo "<b>File:</b> $column_name1 <br /><br />";
echo "<a href=\"$column_name2\">Download</a>";

} else { // someone typed an id that doesnt exist, complain about it
echo "beeeyahhhh!!!! you typed an id that doesn't exist";

} else {
echo "something to do when someone isnt downloading";

i think this is kind of what you are thinking of, but maybe you want to make the php script serve the file so that they don't know the filename?
if you want somehting like that, I can't help you since I've never made anything like that, but I would just google it to find something like that that is already made, or a tutorial

Hope this helps you out, or gets you started.
Related topics
php script in php nuke - need help!
[HELP] script PHP
Need help with php script
Guys, HELP!!! Script wanted!
Help with upload form script! [RESOLVED]
php script help!
Need help making logout script
[Help]Script para autoenvio de formulario
Script error can any one help
Need help with PHP script[RESOLVED]
perl help... script almost working... please help..
Need help with logger script. (half done)
need help with a script for vb its not to hard i think
Help with php and java script
[RESOLVED] phpbb Help with making an upload script.
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

© 2005-2011 Frihost, forums powered by phpBB.