Jump to content

Archived

This topic is now archived and is closed to further replies.

miligraf

Click Counter

Recommended Posts

Hello, i have a click counter that works with a link like this: [b]http://www.yourdomain.com/tutorial.php?id=1[/b] But when i click the link it takes me to that URL and not to the one saved in the SQL table, so i guess its the [b]tutorial.php[/b]. Ive been trying to make it work but i cant :(

tutorial.php

[code]<?
include ('conbd.php');

$query = mysql_query ("SELECT * FROM tutoriales WHERE id='$id'");

while ($row = mysql_fetch_row($query))
{

$id = $row[0];
$enlace = $row[5];

header('Location: '.$enlace);

}

mysql_query ("UPDATE tutoriales SET clics = clics + 1 WHERE id='$id'");
?>[/code]

Thanks for your help!

Share this post


Link to post
Share on other sites
Add this after the include:
$id=$_GET['id'];

Btw, read about SQL injections, because your script is unsecure.

Orio.

Share this post


Link to post
Share on other sites
Negative Orio, still doesnt work :-(

And thx for the suggestion!

I would also like an easy-to-learn php manual, so i will have a better sense on figuring php things out, ty.

Share this post


Link to post
Share on other sites
Injection proof:
[code]$id = $row[0];
$enlace = $row[5];

$id = mysql_escape_string(striptags($id));
$enlace = mysql_escape_string(striptags($enlace));[/code]

Share this post


Link to post
Share on other sites
Maybe its the:
mysql_query ("UPDATE tutoriales SET clics = clics + 1 WHERE id='$id'");

Thats got to be-
$newclics=$clics+1;
mysql_query ("UPDATE tutoriales SET clics='$newclics' WHERE id='$id'");

Orio.

Share this post


Link to post
Share on other sites
Doesnt work either...ive checked the other php where you click the link but it works fine, its this [b]tutorial.php[/b] that isnt working, it doesnt add the click or redirects you to the URL stored in the database. I dunno what happened, it was working fine before but now it doesnt.

Edit: i already figured out the problem, thx for your help!

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.