thcbutterz Posted July 23, 2013 Share Posted July 23, 2013 my goal is to track who is downloading from my server and what they are downloading, and when. I am trying to gather the info for the logged in user, and the file name, in this instance im using movies for an example, and record it to a sql table where i can easily reference it with php my admin.so as of now i have 3 tables set up, one for users, holding all the registration data for my site, username, user id, password email... etc. one for the files holding all the file names with a unique id for each file, and one to log the info to, download tracker, to save the username, user id, email adress, file they are downloading, and a timestamp of when they started the download. so i have set up download links with the movie name in plain text and the movie id as a url variable like this: <a href="/movies/moviehandaler.php$=1" alt="" >movie x </a> <a href="/movies/moviehandaler.php$=2" alt="" >movie y </a> <a href="/movies/moviehandaler.php$=3" alt="" >movie z </a> they will then pass through to a handler page to log the information and pass through to the dowload like this: <?php $user_info = ('username', 'email', 'user_id' FROM `users` WHERE 'user_id' = $session_user_id); //is this right? $movie_id = get['']; //how would i grab the number from the url after "$=" $movie_info = ('movie_name' FROM `movies` WHERE '$movie_id' = 'movie_id'); // is this right? mysql_query(INSERT '$user_info', '$movie_info', 'time', INTO `download_tracker`); // I know this is wrong, how do i fix it? header('Location: /movies/<?php print $movie_info ?>'); //is this even posible? ?> I need help to fix the handaler page so it works... i know im fairly close, i just cant seem to get it right, any help would be greatly apreciated. Quote Link to comment https://forums.phpfreaks.com/topic/280428-need-help-with-a-simple-phpmysql-download-tracker/ Share on other sites More sharing options...
litebearer Posted July 23, 2013 Share Posted July 23, 2013 some reading... passing via url - http://www.html.net/tutorials/php/lesson10.php inserting into db - http://www.tizag.com/mysqlTutorial/mysqlinsert.php Quote Link to comment https://forums.phpfreaks.com/topic/280428-need-help-with-a-simple-phpmysql-download-tracker/#findComment-1441810 Share on other sites More sharing options...
thcbutterz Posted July 23, 2013 Author Share Posted July 23, 2013 some reading... passing via url - http://www.html.net/tutorials/php/lesson10.php inserting into db - http://www.tizag.com/mysqlTutorial/mysqlinsert.php thanks for this, its been a while since i played with php and needed a refresher, so this would be more accurate right? <?php $user_info = ('username', 'email', 'user_id' FROM `users` WHERE 'user_id' = $session_user_id); //is this right? $movie_id = get['id']; $movie_info = ('movie_name' FROM `movies` WHERE '$movie_id' = 'movie_id'); // is this right? mysql_query("INSERT INTO `download_tracker` (user_id, username, email, file, date) VALUES('$user_info['user_id']', '$user_info['username']', '$user_info['email']', '$movie_info['movie_name']', 'time', ) ") or die(mysql_error()); header('Location: /movies/<?php print $movie_info ?>'); //is this even posible? ?> Quote Link to comment https://forums.phpfreaks.com/topic/280428-need-help-with-a-simple-phpmysql-download-tracker/#findComment-1441812 Share on other sites More sharing options...
litebearer Posted July 23, 2013 Share Posted July 23, 2013 did you change the form? this site has good tutorials to learn how to query a db table http://www.tizag.com (re: your user_info and movie_info lines) Quote Link to comment https://forums.phpfreaks.com/topic/280428-need-help-with-a-simple-phpmysql-download-tracker/#findComment-1441815 Share on other sites More sharing options...
PaulRyan Posted July 23, 2013 Share Posted July 23, 2013 You have not connected to the database as far as I am aware, so you need to do that first. Secondly, you are not executing the MySQL queries, just merely assigning them to a variable. You need to look into PHP a bit more look at $_GET. Then you need to move away from MySQL and look to MySQLi also, so read up on that too. Quote Link to comment https://forums.phpfreaks.com/topic/280428-need-help-with-a-simple-phpmysql-download-tracker/#findComment-1441826 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.