-1

this code will display the details of the owner if I enter the application number but it is displaying errors how can i fix the errors please help me

index.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>
Gerald Schneider
  • 17,416
  • 9
  • 60
  • 78
chong
  • 7
  • 3
  • can you post the errors you are getting so someone can help? – mehany Feb 14 '16 at 07:05
  • Undefined index: name in C:\xampp\htdocs\boot\fill.php on line 15 – chong Feb 14 '16 at 07:13
  • Undefined index means one of the column names can not be found. try print_r($result) and show us what gets returned. – mehany Feb 14 '16 at 07:15
  • #4Resource id this came out when i replace mysql_fetch_array with print_r – chong Feb 14 '16 at 07:22
  • try print_r($rowval); die(); after the while loop. the names you specify for each $rowval should exist in the database columns and it is case sensitive. – mehany Feb 14 '16 at 07:24
  • still getting the same error. all the name that i specify are correct – chong Feb 14 '16 at 07:36
  • $_POST[name] is not defined. – SkyMaster Feb 14 '16 at 07:52
  • the action="fill.php" should be index.php, sorry for typographical error – chong Feb 14 '16 at 07:56
  • Thats the error that I cannot fix @SkyMaster – chong Feb 14 '16 at 07:58
  • 1
    Note: The `mysql_*` functions are deprecated, they have been removed from PHP 7, your code will stop working when you upgrade to that version. You should not write new code using them, use [`mysqli_*` or PDO](http://php.net/manual/en/mysqlinfo.api.choosing.php) instead. – Gerald Schneider Feb 14 '16 at 08:09
  • Please read and understand the question before marking for duplication. This is a specific case of that question. That said this question is probably a duplicate of another. – Cem Kalyoncu May 05 '16 at 07:57

2 Answers2

1

You haven't specified the names of the textboxes. Use it like the following:

<input id="Text2" name="name" type="text" disabled value='<?php echo  $Full_name; ?>'/>
Cem Kalyoncu
  • 14,120
  • 4
  • 40
  • 62
0

Try this

$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);
}
paranoid
  • 6,799
  • 19
  • 49
  • 86