Foutje van mij

Gestart doorMertdelft7 reacties21 weergaven

8 berichten · pagina 1 van 1

Mertdelft

Lid · Topicstarter

Berichten
414
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik was bezig met een link systeem alleen ik had een fout, Als je op Klik klikt, krijg je een punt erbij alleen als je weer klikt krijgt die er weer bij, Hoe kun je het zo doen dat het 1 per ip is 24 uur

Hier onder is de code

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]"config.php"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]]) && ([/COLOR][URL="http://www.php.net/is_numeric"]is_numeric[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]]))) {[/COLOR]
[URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE links SET kliks = kliks+1 WHERE id = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[COLOR= #0000BB]$stem[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM links WHERE id = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[COLOR= #0000BB]$stuur[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_object"]mysql_fetch_object[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$stem[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Location: http://"[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$stuur[/COLOR][COLOR= #007700]->[/COLOR]website[COLOR= #007700]);
}[/COLOR]
?>
0
Berichten
5.897
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Werk met mysql_real_escape_string() en bij elke klik zet je in de DB : ad, ip, date en dan kijk je of hij al geklikt heeft.
0
Mertdelft

Lid · Topicstarter

Berichten
414
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Als het goed is, Is dit hem?

[COLOR= #0000BB]<?[/COLOR]
[URL="http://www.php.net/setcookie"]setcookie[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]"links"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$value[/COLOR][COLOR= #007700],[/COLOR][URL="http://www.php.net/time"]time[/URL][COLOR= #007700]()+[/COLOR][COLOR= #0000BB]24[/COLOR][COLOR= #007700];[/COLOR] 
?>

En dit als DB
INSERT TABLE `links` {
`ip` VARCHAR(15) NOT NULL,
PRIMARY KEY (`id`)
0
Berichten
5.897
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Mertdelft schreef:
Als het goed is, Is dit hem?
[COLOR= #0000BB]<?[/COLOR]
[URL="http://www.php.net/setcookie"]setcookie[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]"links"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$value[/COLOR][COLOR= #007700],[/COLOR][URL="http://www.php.net/time"]time[/URL][COLOR= #007700]()+[/COLOR][COLOR= #0000BB]24[/COLOR][COLOR= #007700];[/COLOR] 
?>

En dit als DB
INSERT TABLE `links` {
`ip` VARCHAR(15) NOT NULL,
PRIMARY KEY (`id`)


Je werkt hiervoor best niet met een cookie, want die kan je verwijderen.
En voeg ook een ad_id en date in de DB
0
Mertdelft

Lid · Topicstarter

Berichten
414
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dit wou ik erin doen maar het deed het niet, Heb ik wat Fouts gedaan?

INSERT TABLE `links` {
`ad_id` NOT NULL,
) ENGINE=MyISAM DEFAULT CHARSET
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
CREATE TABLE IF NOT EXISTS `links` (
`ad_id` NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET
0
Mertdelft

Lid · Topicstarter

Berichten
414
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Rik schreef:
CREATE TABLE IF NOT EXISTS `links` (
`ad_id` NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET
Dankje Rik!
0
Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Werk met database of sessies. Sla het ip en dmhet id van de klik op. Leeg de tabel elke dag dmv een cronjob of voeg ook een field met date toe wink
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren