Variabele doorgeven, wat doe ik fout?
Henk
05/02/2006 13:06:00Hallo, ik wil aan mijn socket aanroep een variabele doorgeven maar dit werkt nog niet, moeten nog meer knoppen worden vandaar het javascript iemand idee? thanks
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Untitled</TITLE>
<META NAME="GENERATOR" CONTENT="MAX's HTML Beauty++ 2004">
</HEAD>
<script language="javascript">
function lamp(on_off) {
if(on_off == 1) {document.state.value = "LAMPUIT";
} else {
document.state.value = "LAMPUIT";
}
document.state.submit();
}
</script>
<BODY>
</head>
<body bgcolor="#FFFFFF">
<center>
<form method="post" name="state">
<input type="button" value="LampOn" onclick="lamp(1)">
<input type="button" value="LampOff" onclick="lamp(0)">
</form>
</BODY>
</HTML>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Untitled</TITLE>
<META NAME="GENERATOR" CONTENT="MAX's HTML Beauty++ 2004">
</HEAD>
<script language="javascript">
function lamp(on_off) {
if(on_off == 1) {document.state.value = "LAMPUIT";
} else {
document.state.value = "LAMPUIT";
}
document.state.submit();
}
</script>
<BODY>
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
error_reporting(E_ALL);
/* Allow the script to hang around waiting for connections. */
set_time_limit(0);
/* Turn on implicit output flushing so we see what we're getting
* as it comes in. */
ob_implicit_flush();
$address = '156.52.221.45';
$port = 6000;
//connectie met socket ed
if (($sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP )) < 0) {
echo "socket_create() failed: reason: " . socket_strerror($sock) . "\n";
}
if (($ret = socket_connect($sock, $address, $port)) < 0) {
echo "socket_bind() failed: reason: " . socket_strerror($ret) . "\n";
}
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
//connectie met socket ed
$msg = $_POST['state'];
socket_write($sock, $msg, strlen($msg));
}
?>
error_reporting(E_ALL);
/* Allow the script to hang around waiting for connections. */
set_time_limit(0);
/* Turn on implicit output flushing so we see what we're getting
* as it comes in. */
ob_implicit_flush();
$address = '156.52.221.45';
$port = 6000;
//connectie met socket ed
if (($sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP )) < 0) {
echo "socket_create() failed: reason: " . socket_strerror($sock) . "\n";
}
if (($ret = socket_connect($sock, $address, $port)) < 0) {
echo "socket_bind() failed: reason: " . socket_strerror($ret) . "\n";
}
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
//connectie met socket ed
$msg = $_POST['state'];
socket_write($sock, $msg, strlen($msg));
}
?>
</head>
<body bgcolor="#FFFFFF">
<center>
<form method="post" name="state">
<input type="button" value="LampOn" onclick="lamp(1)">
<input type="button" value="LampOff" onclick="lamp(0)">
</form>
</BODY>
</HTML>
Gewijzigd op 05/02/2006 13:13:00 door Henk
Er zijn nog geen reacties op dit bericht.