-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfollow.php
More file actions
17 lines (17 loc) · 992 Bytes
/
follow.php
File metadata and controls
17 lines (17 loc) · 992 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
require_once('include/header.php');
$from_user_id = htmlentities(mysqli_real_escape_string($con,$_SESSION['id']));
$to_user_id = htmlentities(mysqli_real_escape_string($con,$_POST['to_user_id']));
$query = "SELECT * FROM `follow` WHERE `from_user_id`='$from_user_id' and `to_user_id` = '$to_user_id'";
$run = mysqli_query($con,$query);
$row = mysqli_num_rows($run);
if($row < 1){
$from_user_id = htmlentities(mysqli_real_escape_string($con,$_SESSION['id']));
$to_user_id = htmlentities(mysqli_real_escape_string($con,$_POST['to_user_id']));
$query = "INSERT INTO `follow` (`to_user_id`, `from_user_id`) VALUES ('$to_user_id', '$from_user_id')";
$run = mysqli_query($con,$query);
}
else{
echo "<script>alert('you have already following this user')</script>";
}
?>