I am creating a page that interfaces via tcp/ip with an XML driven application. I must sent all information to the application via XML messages.
I am successfully opening the port and can login when I hard code the login information, but when I created input boxes to pass the login information the XML code I am passing is populated with the name of the variables not the values.
I am passing $account and $pin from another form and trying to insert it into an XML message variable $in. This works hard coded, but not the way it is now. When the application gets the login information it is populated with "$pin" instead of the actual password.
<?php
error_reporting (E_ALL);
echo "<h2>Login</h2>\n";
/ Get the port /
$service_port = '0000';
/ IP address /
$address = '999.99.9.99';
/ Create a TCP/IP socket. /
$socket = socket_create (AF_INET, SOCK_STREAM, 0);
if ($socket < 0) {
echo "socket_create() failed: reason: " . socket_strerror ($socket) . "\n";
} else {
echo "socket Create: OK.<br>\n";
}
echo "Attempting to connect to '$address' on port '$service_port'...";
$result = socket_connect ($socket, $address, $service_port);
if ($result < 0) {
echo "socket_connect() failed.\nReason: ($result) " . socket_strerror($result) . "\n";
} else {
echo "Connection to $address OK.<br>\n";
}
$in = '<Req CodeX="1" Msg="333" Auth=$account Password=$pin></Req>';
$out = '';
echo "$in";
echo "<br>Sending user Login request...";
socket_write ($socket, $in, strlen ($in));
echo "Login Request Sent OK.<br>\n";
echo "Reading response:\n\n";
while ($out = socket_read ($socket, 0000)) {
echo "$out";
}
echo "Closing socket...";
socket_close ($socket);
echo "OK.\n\n";
?>