Php Basit Takipçi Sistemi
Proje Php de basit takipçi sistemidir. Bu proje takipçi sisteminin mantığını basitçe anlamanızı sağlayacaktır.
İndex.php Sayfası
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
<html>
<head>
<title> Takipçi Sistemi</title>
<link rel='stylesheet' href='style.css'/>
</head>
<body>
<?php include 'connect.php'; ?>
<?php include 'functions.php'; ?>
<?php include 'header.php'; ?>
<div id='body'>
</div>
</body>
</html>
|
actions.php Sayfası
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
<?php
include 'connect.php';
include 'functions.php';
$my_id=@$_SESSION('user_id');
$action=$_GET['action'];
$u_id=$_GET['u_id'];
if($action=='follow')
{
mysql_query("INSERT INTO follow VALUES('','$my_id','$u_id')");
}
if($action=='unfollow')
{
mysql_query("DELETE FROM 'follow' WHERE 'user_one'='$my_id' AND 'user_two'='$u_id'");
}
header('location: profile.php?u_id='.$u_id);
?>
|
connect.php Sayfası
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
<?php
@$connect=mysql_connect('localhost','root','');
if($connect)
{
mysql_select_db('twitter');
}
else
{
echo "Host Connecting Error!";
}
?>
|
functions.php Sayfası
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
<?php
session_start();
function loggedin()
{
if(isset($_SESSION['user_id'])&&!empty($_SESSION['user_id']))
{
return true;
}
else
{
return false;
}
}
function getuser($field, $user_id){
$query=mysql_query("SELECT $field FROM users WHERE id='$user_id'");
$run=mysql_fetch_array($query);
return $run[$field];
}
?>
|
header.php Sayfası
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
<div id='header'>
<div id='left'>
<b>Takipçi Sistemi</b>
</div>
<div id='right'>
<a href='index.php'>Anasayfa</a>
<?php
if(loggedin())
{
?>
<a href='profile.php'>Profil</a>
<a href='logout.php'>Çıkış</a>
<?php
} else{
?>
<a href='login.php'>Giriş</a>
<a href='register.php'>Kayıt Ol</a>
<?php
}
?>
</div>
<div class='clear'></div>
</div>
|
login.php Sayfası
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
<html>
<head>
<title>Giriş-Takipçi Sistemi</title>
<link rel='stylesheet' href='style.css'/>
</head>
<body>
<?php include 'connect.php'; ?>
<?php include 'functions.php'; ?>
<?php include 'header.php'; ?>
<div id='body'>
<b>Giriş Yap</b>
<br/><br/>
<form method='post'>
<?php
if(isset($_POST['submit']))
{
$username=$_POST['username'];
$password=$_POST['password'];
if(empty($username)or empty($password))
{
$message="Boş bıraktınız!";
}else{
$check=mysql_query("SELECT id FROM users WHERE username='$username'AND password='".md5($password)."'");
if(mysql_num_rows($check==0))
{
$message="Kullanıcı adı veya şifre yanlış";
}
else{
$run=mysql_fetch_array($check);
$id=$run['id'];
$_SESSION['user_id']=$id;
header('location:index.php');
}
}
echo "<div id='box'>$message</div>";
}
?>
Kullanıcı Adı:<br/>
<input type='text' name='username'/>
<br/><br/>
Şifre:<br/>
<input type='password' name='password'/>
<br/><br/>
<input type='submit' name='submit' value='Giriş'/>
</form>
</div>
</body>
</html>
|
logout.php Sayfası
1
2
3
4
5
6
|
<?php
include 'functions.php';
session_destroy();
header('location:index.php');
?>
|
profile.php Sayfası
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
<html>
<head>
<title> Takipçi Sistemi</title>
<link rel='stylesheet' href='style.css'/>
</head>
<body>
<?php include 'connect.php'; ?>
<?php include 'functions.php'; ?>
<?php include 'header.php'; ?>
<div id='body'>
<?php
$my_id=$_SESSION['user_id'];
if(isset($_GET['u_id'])&&!empty($_GET['u_id'])){
$u_id=$_GET['u_id'];
}else{
$u_id=$_SESSION['user_id'];
}
echo '<b>'.getuser('username',$u_id).'</b>';
?>
<hr/>
<br/>
<?php
if($u_id!=$_SESSION['user_id'])
{
$check=mysql_query("SELECT id FROM follow WHERE user_one='$my_id' AND user_two='$u_id'");
if(mysql_num_rows($check)==1)
{
echo "<a href='actions.php?action=unfollow&u_id=$u_id'>UnFollow</a>";
}else{
echo "<a href='actions.php?action=follow&u_id=$u_id'>Follow</a>";
}
}
?>
<hr/>
Followers:
<?php
$check_followers=mysql_query("SELECT id FROM follow WHERE user_two='$u_id'");
echo mysql_num_rows($check_followers);
?>
<br/>
Followings:
<?php
$check_followings=mysql_query("SELECT id FROM follow WHERE user_one='$u_id'");
echo mysql_num_rows($check_followings);
?>
</div>
</body>
</html>
|
register.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
<html>
<head>
<title>Kayıt Ol-Takipçi Sistemi</title>
<link rel='stylesheet' href='style.css'/>
</head>
<body>
<?php include 'connect.php'; ?>
<?php include 'functions.php'; ?>
<?php include 'header.php'; ?>
<div id='body'>
<b>Kayıt Ol</b>
<br/><br/>
<form method='post'>
<?php
if(isset($_POST['submit']))
{
$username=$_POST['username'];
$password=$_POST['password'];
if(empty($username)or empty($password))
{
$message="Boş bırakılamaz!";
}else{
mysql_query("INSERT INTO users VALUES('','$username','".md5($password)."')");
$message="Kayıt Oldun";
}
echo "<div id='box'>$message</div>";
}
?>
Kullanıcı Adı:<br/>
<input type='text' name='username'/>
<br/><br/>
Şifre:<br/>
<input type='password' name='password'/>
<br/><br/>
<input type='submit' name='submit' value='Kayıt Ol'/>
</form>
</div>
</body>
</html>
|
style.css Sayfası
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
body{
background:#333;
color:#fff;
font-family:lucida sans unicode;
font-size:14px;
margin:0px;
padding:0px;
}
input{
background:#333;
color:#fff;
font-family:lucida sans unicode;
font-size:14px;
padding:10px;
border:0px;
margin:10px 0px;
}
#header{
background:#4aaee7;
color:#fff;
padding:15px;
}
#box{
background:#333;
color:#fff;
padding:10px;
margin:10px 0px;
}
#left{
float:left;
}
#right{
float:right;
}
#header a{
background:#4aaee7;
color:#fff;
text-decoration:none;
padding:10px;
}
#header a:hover{
background:#fff;
color:#4aaee7;
}
#body{
color:#333;
background:#fff;
padding:10px;
width:50%;
margin:30px auto;
min-height:500px;
}
.clear
{
clear:both;
}
|
Projenin veritabanı adı “twitter” olarak verdim ben siz istediğiniz ismi verebilirsiniz. Veritabanımızda iki tane tablo bulunmaktadır. Biri kullanıcıları tutuğumuz “users” ve kullanıcıların takipçilerini tutuğumuz “follow” tablolarıdır.
users tablosu mysql de aşağıdaki gibidir.
follow tablosu mysql de aşağıdaki gibidir.
Projeyi aşağıdaki linkten indirebilirsiniz.
[download id=”2054″]
Yorumlar ( 5 )
aradığım konuydu teşekkürler
$username= mysql_real_escape_string(strip_tags(htmlspecialchars($username)));
$password= mysql_real_escape_string(strip_tags(htmlspecialchars($password)));
Bunları eklemeyi unutmayın. :))
Anlatım çok güzel elinize sağlık,başlıkta da dediğiniz gibi basit bir sistem eğer bunu kullanıcak arkadaş varsa lütfen güvenlik için iyileştirmeler yapsın yoksa siteniz de güvenlik açığı yaratırsınız.
merhaba link kırık düzeltirmisiniz
merhabalar localhostta yukledım calısmasını test etmek ıcın
http://localhost/takipci/actions.php?action=follow&u_id=2
kullanıcıyı takıp et dedıgımızde beyaz ekran cıkıyor verıtabanına kayıtta yaomıyor takıplemeyı.