Help me please to debug a simple page
Posted: Sun Dec 19, 2010 12:34 pm
Hi all,
I'm new to PHP so please forgive me if my question is weird a little...
I got a code from a friend that worked once for him but fails for me.
The code should get the IP address from the PC that runs it,
than, open a file in the web site, name it video.txt and write down this data,
than close that file.
The PHP version is 5.2.14
Any help is very appreciated
Regards
Kishon
I'm new to PHP so please forgive me if my question is weird a little...
I got a code from a friend that worked once for him but fails for me.
The code should get the IP address from the PC that runs it,
than, open a file in the web site, name it video.txt and write down this data,
than close that file.
The PHP version is 5.2.14
Any help is very appreciated
Regards
Kishon
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
<?php
$addr = $_SERVER['REMOTE_ADDR'];
// set file to write
$file = 'video.txt';
// open file
$fh = fopen($file, 'w') or die('Could not open file!');
// write to file
fwrite($fh, $addr) or die('Could not write to file');
// close file
fclose($fh);
?>
<script language="javascript" >
<!--
var str = "<?php echo($addr) ;?>";
function InvokeMethod (str)
{
myDiv.innerHTML = "<font size=8>" + str + "</font>";
}
function Button1_onclick() {
window.external.functionInCSharp(str);
}
function Button2_onclick() {
window.external.AMessageFromHome = "Try try try";
}
function Button3_onclick() {
alert (window.external.AMessageFromHome);
}
-->
</script>
</BODY>
</head>
<body>
<p>myExtentionPage is loaded !</p>
<br />
<br />
<input id="Button1" type="button" value="call CSharp function functionInCSharp" onclick="return Button1_onclick()" /><br />
<br />
<input id="Button3" type="button" value="Show me a message from home !" onclick="return Button3_onclick()" /><br />
<br />
<input id="Button2" type="button" value="Try to change something !" onclick="return Button2_onclick()" /><br />
<br />
<br />
<div id="myDiv" style="font-size: 100%; vertical-align: middle; width: 100%; direction: ltr;
font-family: Fantasy, Sans-Serif, Serif; height: 200px; text-align: center">
</div>
</body>
</html>