Jump to content

Random link generator and Hit counter

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
12 replies to this topic

#1
Blimp

Blimp

    Programmer

  • Members
  • PipPipPipPip
  • 154 posts
Hi Guys!

I don't think i'v ever actually posted on this forum before, so i'd like to say Hi to everyone!

I've recently created a Arcade style website (ConcaveGaming) but I seem to be lacking a lot of traffic. Well, I get about 200-300 visits a day. This is a great start, however, I'm looking to expand this up to about 1000 in the next month.

I thought of an idea of getting users to compete in getting the most hits on my website - the person with the most hits at the end of the month would win a prize. Now, I thought i'd be best asking you PHP guys about this, seeing as it's pretty much all I can use..

So what am I looking to achieve?

Firstly, I need to create a PHP file that will update a users hits every time somebody visits.
For example, if somebody visited: "http://www.concavestudios.com/refer.php?username=[COLOR="rgb(255, 0, 255)"]blimp[/COLOR]"
then the PHP file would recognize this and increment the username (Highlighted in pink) by one.

Secondly, it would be nice if the users could check how many hits they have actually got. However, I don't think there is any need for passwords with this.

Would anybody be able to help me, or should i say, practically script this for me? I have no knowledge of PHP whatsoever and don't think it's a great idea to learn, seeing as I already have a lot of programming languages in my tiny head.

Also, if this helps, i'll put my database details down...

host:ConcaveGaming
username:alex
databasename:users
password:password11

And no, that's not my real password;)

Thanks for your help in advance!

Blimp

#2
Blimp

Blimp

    Programmer

  • Members
  • PipPipPipPip
  • 154 posts
Looks like the highlighting didn't work.. Sorry about that guys. Also, I can't seen to edit it.

#3
plb

plb

    Newbie

  • Members
  • PipPip
  • 18 posts
Hello Blimp.

Add another table of type int to your database, name it whatever you like (for example, hits). You can simply use MySql update to insert new value there.

#4
Blimp

Blimp

    Programmer

  • Members
  • PipPipPipPip
  • 154 posts
I know that. I need to know how to edit the data via PHP.

#5
plb

plb

    Newbie

  • Members
  • PipPip
  • 18 posts
<?php
$conn = mysql_connect("host", "user", "password");
mysql_select_db("database_name") or die(mysql_error());

mysql_query("UPDATE table_name SET hit = '$new_value' WHERE name = '$user';");

mysql_close($conn);

?>

#6
Blimp

Blimp

    Programmer

  • Members
  • PipPipPipPip
  • 154 posts
And what will this do?

#7
plb

plb

    Newbie

  • Members
  • PipPip
  • 18 posts
this code will be part of a page, when user loads it this will update user's hits with new value. new_value = old_value + 1. I hope you know how to get data from MySql.

#8
Blimp

Blimp

    Programmer

  • Members
  • PipPipPipPip
  • 154 posts
Okay. Well, I'm guessing that using this snippet in my script and replacing the database name,password and table should do the trick?

#9
plb

plb

    Newbie

  • Members
  • PipPip
  • 18 posts
I hope so. If there is something else, I'll try to help you.

#10
Blimp

Blimp

    Programmer

  • Members
  • PipPipPipPip
  • 154 posts
Thanks. Would you be able to email me on:
admin@concavestudios.com

As i'm not sure how to set up the table properly. thanks!

#11
plb

plb

    Newbie

  • Members
  • PipPip
  • 18 posts
You can use phpmyadmin. It is very simple.

#12
DEViANT

DEViANT

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 358 posts
Actually, the SQL query can be made much easier. This will work :

Quote

UPDATE table_name SET hit = hit+1 WHERE name = '$user';

:D You should rep+ me so that I can win :D

My Blog | Ask me!
Error : Satan did it