当程序直接运行时我收到一条错误消息,但是当我单击搜索按钮时它可以正常工作。
错误消息是Notice: Undefined index no in [...] on line 21
,第 21 行是$no1 = $_POST['no'];
我该如何解决?
这是我的完整代码:
<html>
<head>
<title> Searching </title>
</head>
<body>
<form method="POST" action="out.php">
<table border="0" cellpadding="5" cellspacing="0">
<tbody>
<tr>
<td> No </td>
<td>:</td>
<td> <input type="text" name="no"> </td>
<td> <input type="SUBMIT" name="SUBMIT" id="SUBMIT" value="search" >
<?php
include('connect.php');
$no1 = $_POST['no'];
$no = strtoupper($no1);
$query = mysql_query("select no, type, time from park where no = '$no'") or die(mysql_error());
$data = mysql_fetch_array($query);
?>
</td>
</tr>
<tr>
<td>Type</td>
<td>:</td>
<td><input type="text" name="type" maxlength="30" value= "<?php echo $data['type']; ?>" /></td>
</tr>
<tr>
<td>Time</td>
<td>:</td>
<td><input type="text" name="time" maxlength="4" value= "<?php echo $data['time']; ?>" //></td>
</tr>
<tr></tr>
</tbody>
</table>
</form>
</body>
</html>
和截图: