Issues (46)

unfollow.php (1 issue)

Severity
1
<?php require($_SERVER['DOCUMENT_ROOT'] . "/static/config.inc.php"); ?>
2
<?php require($_SERVER['DOCUMENT_ROOT'] . "/static/conn.php"); ?>
3
<?php require($_SERVER['DOCUMENT_ROOT'] . "/lib/profile.php"); ?>
4
5
<?php
6
    $name = $_GET['n'];
7
8
    if(!isset($_SESSION['siteusername']) || !isset($_GET['n'])) {
9
        $_SESSION['errorMsg'] = ("You are not logged in");
10
        goto skip;
11
    }
12
13
    if($name == $_SESSION['siteusername']) {
14
        $_SESSION['errorMsg'] = ("You can't unfollow yourself");
15
        goto skip;
16
    }
17
18
    $stmt = $conn->prepare("SELECT * FROM follow WHERE sender = ? AND reciever = ?");
19
    $stmt->bind_param("ss", $_SESSION['siteusername'], $name);
20
    $stmt->execute();
21
    $result = $stmt->get_result();
22
    if($result->num_rows === 0) {
23
        $_SESSION['errorMsg'] = ('You havent followed this person');
24
        goto skip;
25
    }
26
    $stmt->close();
27
28
    $stmt = $conn->prepare("DELETE FROM follow WHERE sender = ? AND reciever = ?");
29
    $stmt->bind_param("ss", $_SESSION['siteusername'], $name);
30
    $stmt->execute();
31
    $stmt->close();
32
    skip:
33
34
    header('Location: ' . $_SERVER['HTTP_REFERER']);
35
?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...