如何在没有功能的情况下以Html格式存储IP地址?

时间:2012-08-23 05:21:47

标签: php html forms ip ip-address

所以当我在谷歌浏览器中打开它时,我继续收到以下错误:

此页面包含以下错误:

第28行第60行的

错误:未转义为'<'不允许在属性值中 下面是第一个错误的页面呈现。

但我看到有很多人以这种方式获得IP地址的例子。我做错了什么?

    <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>GradeYourTeacher.Com</title>
<style type="text/css">
p{
    color:black;
    f ont-size:14pt;
    font-family: "Comic Sans MS", cursive, sans-serif;
}
h1 {
    color:purple;
    text-align:center;
    font-size:36pt;
    font-family: "Trebuchet MS", Helvetica, sans-serif;
}
</style>
</head>
<!--This Website is made by Francisco Sanchez-->
<!--Try to get IP Address echo $_SERVER['REMOTE_ADDR'];  -->
<body>
<h1>Grade Your Teacher</h1>
<p>
<form id="myform" action="http://learncompsci.com/web/examples/forms/formReader.php" method="get">
To Grade Your Teacher Please Enter The Following Information:
<br/>
<br/>
Display Name: &nbsp; <input name="loginName" type="text" id="loginName" size="14" maxlength="32"/> (For others to view)
<br/>
Email: &nbsp; <input name="email" type="text" id="email" size="20" maxlength="64"/>
<br/>
Email: &nbsp; <input name="password" type="password" id="password" size="14" maxlength="32"/>
<br/>
Confirm Password: &nbsp; <input name="passwordConfirm" type="password" id="passwordConfirm" size="10" maxlength="20" /><br />
First Name:: &nbsp; <input name="firstName" type="text" id="firstName" size="20" maxlength="40" /><br />
Grad Year:: &nbsp; <select name="gradYear" id="gradYear">
      <option value="08">2008</option>
      <option value="09">2009</option>
      <option value="10">2010</option>
      <option value="11">2011</option>
    </select><br />
Gender:: &nbsp; <input name="gender" type="radio" value="male" checked="checked" />
      male &nbsp; &nbsp; 
      <input type="radio" name="gender" value="female" />
      female<br />
Sports: &nbsp; <input type="checkbox" name="sports" value="track" />
      track &nbsp; &nbsp; 
      <input type="checkbox" name="sports" value="baseball" />
      baseball &nbsp; &nbsp; 
      <input type="checkbox" name="sports" value="lacrosse" />      
      lacrosse &nbsp; &nbsp; 
      <input type="checkbox" name="sports" value="paintball" />
paintball
<br />
    Banter: &nbsp; <textarea name="banter" cols="30" rows="5" id="banter"></textarea><br />
    <input type="submit" name="Submit" value="Enter" />
    <input type="hidden" id="IP" name="IP" value= "<?php echo $_SERVER['REMOTE_ADDR']; ?>" />

<br/>
</form>
</p>    
</body>
</html>

1 个答案:

答案 0 :(得分:2)

您需要让PHP引擎解析脚本/页面,以使PHP代码正常工作。

或以更简单的方式说;你需要把它放在你的网络服务器上。

通常,PHP初学者开始使用便宜的托管解决方案 - 以节省费用 - 安装WAMP,一个简单的安装包,包含在本地解析PHP的基本要素 - Apache(网络服务器),MySQL (数据库),当然还有PHP,允许Apache解析你的脚本。

尝试使用某些托管或在本地安装某些内容。