如何在页面中使用PHP语言打开指定文件

来源:百度知道 编辑:UC知道 时间:2024/09/25 01:16:52
我用dreamweaver做了个页面,想在其中的文本框内显示地址上指定路径的文本文件,请问下该怎么添加修改PHP语句。
页面源代码如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Examine Rule</title>
</head>

<body>

<h1 align="center">Display Rule</h1>
<div align="center">
<table width="426" height="300" border="1">
<tr>
<td height="34" colspan="2"> <div align="center">choose rules</div>
<form name="form2" method="post" action="">
<div align="center">Location:
<input name="textfield" type="text" size="60">
</div>
</form> </td>
</tr>
<

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Examine Rule</title>
</head>

<body>
<?php
$file = $_POST[textfield];
if($file&&$_POST[Submit])
{
$handle = file("$file");
if(is_array($handle))
{
$str = "";
foreach($handle as $k => $v)
{
$str.=$v;
}
}
}
?>
<h1 align="center">Display Rule</h1>
<div align="center">
<form name="form1" method="post" action="">
<table width="426" height="300" border="1">
<tr>
<td height="34" colspan="2"> <div align="center">choose rules</div>
<div align="center"&g