Page 1 of 1

A little change to this unique visiter script...help?

Posted: Sat Jun 16, 2007 11:26 am
by gaogier
hello,

I wish to use, this script found in this tutorial

http://www.spoono.com/php/tutorials/tutorial.php?id=16


My only question, is, how can i make it so that it will put up all the users on the site, so the script wont show on all pages, just the main page?

This will go on different places on the site, forums, desktop, a game.

Posted: Sat Jun 16, 2007 1:09 pm
by Luke
My only question, is, how can i make it so that it will put up all the users on the site, so the script wont show on all pages, just the main page?
I'm not sure I know exactly what you're asking. Try and give more details when you ask a question please. If I understand you correctly, you want to display how many users are on your site, but only on your home page. If that's what you're asking, it says in the second sentence on that page how to do it.
This script will explain how to display the number of users online using your website. You have to put this on everypage you want it to appear.
If you don't want it to show up on a certain page, don't put it on that page.

I have to advise against this script though. It's very poorly written. Why?

For one, it requires register_globals to be turned on, which I try to never do unless absolutely necessary.

Also, this just $PHP_SELF right into the query, totally unchecked. Did you know that PHP_SELF contains user input? This opens you up to SQL injection. There are better methods of getting the current file, for example -- basename(__FILE__).

Code: Select all

//insert the values
$insert = mysql_db_query($database, "INSERT INTO useronline VALUES
('$timestamp','$REMOTE_ADDR','$PHP_SELF')"); 
if(!($insert)) { 
print "Useronline Insert Failed > "; 
}
This is why I generally discourage online tutorials to PHP newcomers. People don't have to know what they're doing to write a tutorial. They just have to think they know what they're doing. A good majority of the tutorials you'll find on the internet are total crap.

If you explain more about your website / application, maybe I can help you roll your own?

Descriptive subjects

Posted: Sat Jun 16, 2007 3:44 pm
by feyd
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:2. Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.

Re: Descriptive subjects

Posted: Sat Jun 16, 2007 4:20 pm
by gaogier
feyd wrote:
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:2. Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.
Sorry, i thought it was descriptive as much as i could think at the time.






Also, what im trying to do, is, show all the users who have gone on the site, even if there is no script.

I have forums, topsites, a RPG, and a site, which all uses, php's include files. so i can just put the file on the header, or footer.

But i dont want the script so show, on the RPG, Topsites, and the forums, just the main site, i know php wont show in the source, but can it not be shown in the page?

Posted: Sat Jun 16, 2007 4:37 pm
by Luke
yes, you just include all the necessary logic in your "php's include files", then echo out the result only on the pages you want it to show up on. Once again, I'd advise against using this script, or at least modifying this script to not suck so much.

Posted: Sat Jun 16, 2007 5:37 pm
by gaogier
would anyone know where i can find such a good tut, what can do what i want?

Posted: Sat Jun 16, 2007 6:17 pm
by Luke
If you make an honest attempt to write it yourself, and then you run into troubles, ask questions here, I'm sure that this community will help you.

Posted: Sat Jun 16, 2007 6:24 pm
by gaogier
im not that great with php


I would have to use a book, but the book i use is the same book as what they use

Posted: Sat Jun 16, 2007 7:26 pm
by superdezign
But you have so much on your site?

What you want to do is have every page that you want counted to check who's visited and store it, and then just output it to the page you want to output it to. PHP only exists where you make it...

Posted: Sat Jun 16, 2007 7:37 pm
by Luke
gaogier wrote:im not that great with php
The only way to get great with php is to use it. You will never get any better at it by having people tell you how to do everything. Use the code you found in that tutorial, and rewrite it to do exactly what you want. We'll help you, but I don't see "I'm not that great with php" as a good enough reason why you can't write it on your own (with our guidance of course)

Posted: Sun Jun 17, 2007 9:07 am
by gaogier
a few of the scripts was created, and the rest was done by me.

Also, iv changed the name of this post.
superdezign wrote:But you have so much on your site?

What you want to do is have every page that you want counted to check who's visited and store it, and then just output it to the page you want to output it to. PHP only exists where you make it...
thats what i want.

Posted: Sun Jun 17, 2007 9:40 am
by superdezign
I'm aware that it is what you want... That's why I said that it was what you want. :lol:

So, make it. It's just a little SQL interaction.