403Webshell
Server IP : 127.0.0.1  /  Your IP : 216.73.216.48
Web Server : Apache/2.4.58 (Win64) OpenSSL/3.1.3 PHP/8.2.12
System : Windows NT DESKTOP-3H4FHQJ 10.0 build 19045 (Windows 10) AMD64
User : win 10 ( 0)
PHP Version : 8.2.12
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : OFF |  Perl : OFF |  Python : OFF |  Sudo : OFF |  Pkexec : OFF
Directory :  D:/xampp/htdocs-coblaa/pureFaith/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : D:/xampp/htdocs-coblaa/pureFaith/insert_comment.php
<?php
session_start();
include('db.php');

header('Content-Type: application/json');

if (!isset($_SESSION['my_id']) || empty($_SESSION['my_id'])) {
    http_response_code(401);
    echo json_encode(['success' => false, 'message' => 'User not logged in.']);
    exit();
}

$userId = $_SESSION['my_id'];
$data = json_decode(file_get_contents("php://input"), true);

$videoId = $data['videoId'] ?? null;
$commentText = $data['comment'] ?? null;

if (!$videoId || empty($commentText)) {
    http_response_code(400);
    echo json_encode(['success' => false, 'message' => 'Missing video ID or comment text.']);
    exit();
}

// Ensure the userId is an integer. Change to (string) if your DB column is VARCHAR.
$userId = (int)$userId; 
$videoId = (int)$videoId;

// Use 'iis' assuming your database columns are INT, INT, and STRING.
$stmt = $con->prepare("INSERT INTO clip_commenttb (videoId, userId, clip_comment) VALUES (?, ?, ?)");

if ($stmt) {
    // Correctly bind parameters. 'i' for integer, 's' for string.
    $stmt->bind_param("iis", $videoId, $userId, $commentText);

    if ($stmt->execute()) {
        echo json_encode(['success' => true, 'message' => 'Comment added successfully.']);
    } else {
        http_response_code(500);
        echo json_encode(['success' => false, 'message' => 'Database error: ' . $stmt->error]);
    }

    $stmt->close();
} else {
    http_response_code(500);
    echo json_encode(['success' => false, 'message' => 'Failed to prepare the statement: ' . $con->error]);
}

$con->close();
?>

Youez - 2016 - github.com/yon3zu
LinuXploit