the-real-sumsome /
witter
| 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 follow 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 === 1) { |
||
| 23 | $_SESSION['errorMsg'] = 'You already followed this person'; |
||
| 24 | goto skip; |
||
| 25 | } |
||
| 26 | $stmt->close(); |
||
| 27 | |||
| 28 | $stmt = $conn->prepare("INSERT INTO follow (sender, reciever, status) VALUES (?, ?, 'u')"); |
||
| 29 | $stmt->bind_param("ss", $_SESSION['siteusername'], $name); |
||
| 30 | |||
| 31 | $stmt->execute(); |
||
| 32 | $stmt->close(); |
||
| 33 | |||
| 34 | skip: |
||
| 35 | header('Location: ' . $_SERVER['HTTP_REFERER']); |
||
| 36 | ?> |
||
|
0 ignored issues
–
show
|
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.