simpel-linksysteem
---MySQL---
CREATE TABLE `links` (
`id` int(11) NOT NULL auto_increment,
`naam` text NOT NULL,
`website` text NOT NULL,
`clicks` varchar(100) NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ;
---config.php---
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
// Script gemaakt door
// Edwin [email protected]
// Davey
//
// www.baed-net.eu
//
// Verander hieronder je eigen instellingen
$database ="tut"; // Zet hier je database naam neer
$server ="localhost"; // Verander naar je database host
$user ="root"; // Database username
$wachtwoord =""; // Wachtwoord
// Niks meer veranderen hieronder
mysql_connect("$server","$user", "$wachtwoord");
mysql_select_db("$database");
?>
// Script gemaakt door
// Edwin [email protected]
// Davey
//
// www.baed-net.eu
//
// Verander hieronder je eigen instellingen
$database ="tut"; // Zet hier je database naam neer
$server ="localhost"; // Verander naar je database host
$user ="root"; // Database username
$wachtwoord =""; // Wachtwoord
// Niks meer veranderen hieronder
mysql_connect("$server","$user", "$wachtwoord");
mysql_select_db("$database");
?>
---index.php---
Code (php)
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
<?php
include "config.php";
$query = "SELECT * FROM links ORDER BY clicks DESC";
$info =mysql_query($query) or die ("Error!");
print "<table>";
while ($link = mysql_fetch_array($info)) {
print "<tr><td>".$link['id']."</td><td>".$link['naam']."</td><td><a href='click.php?id=".$link['id']."'>Kliks: ".$link['clicks']."</a></tr>";
}
print "</table>";
print "<br>Copyright by <a href='http://baed-net.eu'>Baed Soft</a>";
?>
include "config.php";
$query = "SELECT * FROM links ORDER BY clicks DESC";
$info =mysql_query($query) or die ("Error!");
print "<table>";
while ($link = mysql_fetch_array($info)) {
print "<tr><td>".$link['id']."</td><td>".$link['naam']."</td><td><a href='click.php?id=".$link['id']."'>Kliks: ".$link['clicks']."</a></tr>";
}
print "</table>";
print "<br>Copyright by <a href='http://baed-net.eu'>Baed Soft</a>";
?>
---add.php---
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<title>Links</title>
<?php
include "config.php";
if(isset($_GET['actie']) && ($_GET['actie'] == "post")) {
$naam = $_POST['naam'];
$url = $_POST['url'];
if (empty($_POST['naam']) || empty($_POST['url'])) {
print "Je hebt je naam en/of website vergeten in te vullen";
}else{
mysql_query("INSERT INTO links (naam, website) VALUES ('".$naam."', '".$url."')") or die(mysql_error());
print "URL toegevoegt!";
}
} else {
?>
<form method="post" action="?actie=post">
Naam website: <input type="text" name="naam"><br>
Website: <input type="text" name="url"><br>
<input type="submit" name="submit" value="Verzend!"> <input type="reset" value="Reset!">
</form>
<?php
}
?>
<?php
include "config.php";
if(isset($_GET['actie']) && ($_GET['actie'] == "post")) {
$naam = $_POST['naam'];
$url = $_POST['url'];
if (empty($_POST['naam']) || empty($_POST['url'])) {
print "Je hebt je naam en/of website vergeten in te vullen";
}else{
mysql_query("INSERT INTO links (naam, website) VALUES ('".$naam."', '".$url."')") or die(mysql_error());
print "URL toegevoegt!";
}
} else {
?>
<form method="post" action="?actie=post">
Naam website: <input type="text" name="naam"><br>
Website: <input type="text" name="url"><br>
<input type="submit" name="submit" value="Verzend!"> <input type="reset" value="Reset!">
</form>
<?php
}
?>
---delete.php---
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<title>Delete</title>
<?php
include "config.php";
if(isset($_GET['actie']) && ($_GET['actie'] == "post")) {
$id = $_POST['id'];
if (empty($_POST['id'])) {
print "Je hebt de id vergeten in te vullen";
}else{
mysql_query("DELETE FROM links WHERE id = ".$id."") or die(mysql_error());
print "Je link is suc6 vol verwijdert!";
}
} else {
?>
<form method="post" action="?actie=post">
ID: <input type="text" name="id"><br>
<input type="submit" name="submit" value="Verzend!"> <input type="reset" value="Reset!">
</form>
<?php
}
?>
<?php
include "config.php";
if(isset($_GET['actie']) && ($_GET['actie'] == "post")) {
$id = $_POST['id'];
if (empty($_POST['id'])) {
print "Je hebt de id vergeten in te vullen";
}else{
mysql_query("DELETE FROM links WHERE id = ".$id."") or die(mysql_error());
print "Je link is suc6 vol verwijdert!";
}
} else {
?>
<form method="post" action="?actie=post">
ID: <input type="text" name="id"><br>
<input type="submit" name="submit" value="Verzend!"> <input type="reset" value="Reset!">
</form>
<?php
}
?>
---click.php---
Code (php)
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
<?php
include "config.php";
if(isset($_GET['id']) && (is_numeric($_GET['id']))) {
mysql_query("UPDATE links SET clicks = clicks+1 WHERE id = '".$_GET['id']."'") or die(mysql_error());
$hamburger = mysql_query("SELECT * FROM links WHERE id = '".$_GET['id']."'") or die(mysql_error());
$sla = mysql_fetch_object($hamburger);
header("Location: http://".$sla->website);
exit("U wordt doorgestuurd");
}
?>
include "config.php";
if(isset($_GET['id']) && (is_numeric($_GET['id']))) {
mysql_query("UPDATE links SET clicks = clicks+1 WHERE id = '".$_GET['id']."'") or die(mysql_error());
$hamburger = mysql_query("SELECT * FROM links WHERE id = '".$_GET['id']."'") or die(mysql_error());
$sla = mysql_fetch_object($hamburger);
header("Location: http://".$sla->website);
exit("U wordt doorgestuurd");
}
?>