PHP初学者,在线求高手解决,20分相送!!!
小弟初学PHP,写了个价格竞猜程序,分三个页面:填写竞猜表格(guessform.htm),处理表格程序(processorder.php),管理员查看程序(vieworders.php),但是我每次提交过后都不能把填写的值传过去,而且提交后会还显示下面的代码:
flock(): supplied argument is not a valid stream resource in D:\wwwroot\processorder.php on line
而调用vieworder.php时又会显示:
fopen(..\orders\orders.txt): failed to open stream: No such file or directory in D:\wwwroot\vieworders.php on line 10 PHP Warning: flock(): supplied argument is not a valid stream resource in D:\wwwroot\vieworders.php on line 12 求哪位大侠解答以下
求救
guessform.htm:
<html>
<head>
<title>竞猜</title>
</head>
<body>
<h1>竞猜</h1>
<h2>请填写你的资料</h2>
<form action="processorder.php" method=post>
<table border=0>
<tr bgcolor=#cccccc>
<td class="h">姓名</td>
<td class="d"><input name="name" type="text" class="text" size="25" id="name"></td>
</tr>
<tr bgcolor=#cccccc>
<td width=150>性别</td>
<td class="d">男<input name="gender" type="radio" value="M" checked>
女<input name="gender" type="radio" value="F"></td>
</tr>
<tr bgcolor=#cccccc>
<td class="h">生日</td>
<td class="d">
<select name="year" id="year">
{loop:dispYear}
<option value='{tag:dispYear[] /}'>{tag:dispYear[] /}</option>
{/loop:dispYear}
</select>
年
<select name="month" id="month">
{loop:dispMonth}
<option value='{tag:dispMonth[] /}'>{tag:dispMonth[] /}</option>
{/loop:dispMonth}
</select>
月
<select name="day" id="day">
{loop:dispDay}
<option value='{tag:dispDay[] /}'>{tag:dispDay[] /}</option>
{/loop:dispDay}
</select>
日</td>
</tr>
<tr bgcolor=#cccccc>
<td class="h">身份证号码</td>
<td class="d"><input name="identid" type="text" class="text" size="25" id="identid"></td>
</tr>
<tr bgcolor=#cccccc>
<td class="h" >联系地址</td>
<td class="d"><input name="address" type="text" class="text" size="25" id="address"></td>
</tr>
<tr bgcolor=#cccccc>
<td class="h">联系邮编</td>
<td class="d"><input name="ad_postcode" type="text" class="text" size="25" id="ad_postcode"></td>
</tr>
<tr bgcolor=#cccccc>
<td class="h">联系电话</td>
<td class="d"><input name="tel" type="text" class="text" size="25" id="tel"></td>
</tr>
<tr bgcolor=#cccccc>
<td class="h">电子邮件</td>
<td class="d"><input name="email" type="text" class="text" size="25" id="email"></td>
</tr>
<tr bgcolor=#cccccc>
<td colspan=2>
您认为的报价是:
</td>
</tr>
<tr bgcolor=#cccccc>
<td>卖价</td>
<td>¥<input name="sell_price" type="text" class="text" size="7" id="sell_price"></td>
<tr bgcolor=#cccccc>
<tr bgcolor=#cccccc>
<td>买价</td>
<td>¥<input name="sell_price" type="text" class="text" size="7" id="sell_price"></td>
<tr bgcolor=#cccccc>
<td colspan=2 ><input type="submit" value="确定">
<input type="reset" value="重新填写"></td>
</tr>
</table>
</form>
</body>
</html>
processorder.php:
<html>
<head>
<title>竞猜</title>
</head>
<body>
<h1>资料</h1>
<?
$date = date("H:i, jS F");
echo "<p>参加时间 ";
echo $date;
echo "<br>";
echo "<p>您填写得资料如下:<br>";
echo "姓名:".$name."<br>";
echo "性别:".$gender."<br>";
echo "生日:".$year."年".$month."月".$day."日<br>";
echo "身份证号:".$identid."<br>";
echo "您竞猜输入的卖价:¥".$sell_price."<br>";
echo "您竞猜输入的买价:¥".$buy_price."<br>";
$outputstring = $date."\t姓名".$name."\t性别".$gender.
"\t生日:".$year."年".$month."月".$day."日\t身份证号".$identid
."\t卖价".$sell_price."\t买价".$buy_price."\n";
// open file for appending
@ $fp = fopen("/orders/orders.txt", "a");
flock($fp, 2);
if (!$fp)
{
echo "<p><strong> 系统忙!请重新发送
</strong></p></body></html>";
exit;
}
fwrite($fp, $outputstring);
flock($fp, 3);
fclose($fp);
echo "<p>资料已写入.</p>";
?>
</body>
</html>
vieworders.php:
<html>
<head>
<title>详细表</title>
</head>
<body>
<h1>详细表</h1>
<?
$fp = fopen("/orders/orders.txt", "r");
flock($fp, 1);
if (!$fp)
{
echo "<p><strong>目前没有任何人填写!
</strong></p></body></html>";
exit;
}
while (!feof($fp))
{
$order= fgets($fp, 100);
echo $order."<br>";
}
flock($fp, 3);
fclose($fp);
?>
</body>
</html>