Sindbad~EG File Manager

Current Path : /usr/home/beeson/public_html/michaelbeeson/Testing/
Upload File :
Current File : /usr/home/beeson/public_html/michaelbeeson/Testing/index.php

<!DOCTYPE html>
<html>
<head>
    <title>PHP to C Socket Example</title>
</head>
<body>
    <form action="index.php" method="post">
        <input type="text" name="data" placeholder="Enter data">
        <input type="submit" value="Send">
    </form>

    <?php
    if ($_SERVER["REQUEST_METHOD"] === "POST") {
        $data = $_POST["data"];
        
        // Create a socket connection to the C program
        $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
        $result = socket_connect($socket, "127.0.0.1", 12345);
        
        if ($result) {
            // Send data to the C program
            socket_write($socket, $data, strlen($data));
            socket_close($socket);
            
            echo "Data sent successfully: $data";
        } else {
            echo "Failed to connect to the C program.";
        }
    }
    ?>
</body>
</html>

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists