我正在获取未定义的索引:C:xampphtdocsootfill.php 中的名称,在第 15 行


Im getting Undefined index: name in C:xampphtdocsootfill.php on line 15

如果我

输入应用程序编号,此代码将显示所有者的详细信息,但它显示错误如何修复错误,请帮助我

索引.php

<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("db_test", $con);
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("db_test", $con);
//$sql="select * from tbl_owner";
$result = mysql_query("select * from tbl_owner where    Application_no='$_POST[name]'");
while($rowval = mysql_fetch_array($result))
 {
$name = $_POST['name'];
$Application_no= $rowval['Application_no'];
$Full_name= $rowval['Full_name'];
$contact= $rowval['contact'];
$residence= $rowval['residence'];
$age= $rowval['age'];
$status= $rowval['civil_status'];
$spouse= $rowval['name_of_spouse'];
$goods= $rowval['kind_of_goods'];
}
mysql_close($con);
?>
<html>
<head><title></title>
</head>
<body>
<form action="fill.php" method="post">
<table style="color:purple;border-style:groove; height:150px;width:350px"            background="backimage.jpg">
<tr>
<td style=" height:25px; font-family:'Copperplate Gothic Bold'">&nbsp;   </td>
 </tr>
<tr>
<td style="color:red;background-color:aqua;height:25px">Enter Account no
                <input name="name"  type="text"/></td>
        </tr>
<tr>
<td style="height:25px">
<input type="submit" value="Submit"          style="color:white;background-color:brown; height:30px" /></td>
        </tr>
 </table>
</form>
<span>
<table name="tab" style="color:purple;border-style:groove; height:150px;width:350px" background="3.jpg">
    <tr>
<td style="font-family:Copperplate Gothic Bold"></td>
    </tr>
        <tr>
            <td style="height:25px">
                       <input type="submit" value="Submit" style="color:white;background-color:brown; height:30px" /></td>
        </tr>
    <tr>
        <td style="color:red;background-color:aqua;" class="auto-style3">Account no:</td>
        <td class="auto-style4">
            <input id="Text1" type="text"  value='<?php echo  $Application_no; ?>'/></td>
    </tr>
    <tr>
        <td style="color:red;background-color:aqua;" class="auto-style3">Fullname</td>
        <td class="auto-style4">
            <input id="Text2" type="text" disabled value='<?php echo  $Full_name; ?>'/></td>
    </tr>
    <tr>
         <td style="color:red;background-color:aqua;" class="auto-style3">Contact:</td>
        <td class="auto-style4">
            <input id="Text3" type="text" disabled value='<?php echo  $contact; ?>' /></td>
    </tr>
    <tr>
         <td style="color:red;background-color:aqua;" class="auto-style3">Residence:</td>
        <td class="auto-style4">
            <input id="Text4" type="text" disabled value='<?php echo  $residence; ?>' /></td>
    </tr>
    <tr>
         <td style="color:red;background-color:aqua;" class="auto-style3">Age:</td>
        <td class="auto-style4">
            <input id="Text4" type="text" disabled value='<?php echo  $age; ?>' /></td>
    </tr>
    <tr>
         <td style="color:red;background-color:aqua;" class="auto-style3">Civil Status:</td>
        <td class="auto-style4">
            <input id="Text4" type="text" disabled value='<?php echo  $status; ?>' /></td>
    </tr>
    <tr>
         <td style="color:red;background-color:aqua;" class="auto-style3">Spouse:</td>
        <td class="auto-style4">
            <input id="Text4" type="text" disabled value='<?php echo  $spouse; ?>' /></td>
    </tr>
    <tr>
         <td style="color:red;background-color:aqua;" class="auto-style3">kind of goods:</td>
        <td class="auto-style4">
            <input id="Text4" type="text" disabled value='<?php echo  $goods; ?>' /></td>
    </tr>
    <tr>
        <td></td>
    </tr>
</table>
</span>
</body>
</html>

尚未指定文本框的名称。像下面这样使用它:

<input id="Text2" name="name" type="text" disabled value='<?php echo  $Full_name; ?>'/>

试试这个

$name='';
 $Application_no='';
 $Full_name='';
 $contact=''; 
 $residence='';
 $age='';
 $status='';
 $spouse='';
 $goods='';
if(isset($_POST['name'])){
   $result = mysql_query("select * from tbl_owner where    Application_no='{$_POST[name]}'");
  while($rowval = mysql_fetch_array($result))
   {
 $name = $_POST['name'];
 $Application_no= $rowval['Application_no'];
 $Full_name= $rowval['Full_name'];
 $contact= $rowval['contact'];
 $residence= $rowval['residence'];
 $age= $rowval['age'];
 $status= $rowval['civil_status'];
 $spouse= $rowval['name_of_spouse'];
 $goods= $rowval['kind_of_goods'];
 }
 mysql_close($con);
}