0

i have database name "predefine_value" and in that database i stored registr_no,aircraft_type and mtow, what i want is when user input registration number into input field to use registration number field in database query and retrieve aircraft_type and mtow from the database and to automatically filled aircraft_type and mtow field in the form. i don't javascript please help

Just Side note i am network engineer by trade i took this project as volunteer since i did couple of php project back in university.i am not worry about security issue because this will be locally hosted and few computer will have access to this server.

<table>
        <form method="post" action="">
            <tr>

            <?php
                include ("connect.php");
                global $con;  
                $g = mysqli_query($con,"select max(id) from plane_info");
                while($id=mysqli_fetch_array($g))
                {
            ?>

                <th>ID:</th>
                <td><input type="text" name="txtid" value="<?php echo $id[0]+1; ?>" readonly="readonly" /></td>
            </tr>
            <?php
                }
            ?>

            <tr>
                <th>Registration No:</th>
                <td><input type="text" name="txtregistr_no" /></td>
            </tr>
            <?php

                $registr_no=txtregistr_no;
                $k = mysqli_query($con1,"select aircraft_type mtow from predefine_value where registr_no=".$registr_no);
                while($registr_no=mysqli_fetch_array($k))
                {
                }
            ?>
            <tr>
                <th>Aircraft_type:</th>
                <td><input type="text" name="aircraft_type" value="<?php echo $registr_no[1];?>"  /></td>
            </tr>
            <tr>`
                <th>MTOW:</th>
                <td><input type="text" name="mtow" value="<?php echo $registr_no[2];?>"  /></td>
            </tr>
  • 2
    what's not working the way you would like it to be? or are you asking us to give you guidance/how to make it work? – Funk Forty Niner Oct 27 '17 at 14:36
  • 2
    Side note: `
    ` cannot be made child of ``.
    – Funk Forty Niner Oct 27 '17 at 14:37
  • You either need to split up your form or use Javascript. I'd also suggest to take another look at the way you build your HTML. – Peter M Oct 27 '17 at 14:37
  • You need to use AJAX to retrieve aircraft_type from database based on 'txtregistr_no' input. – Ravinder Reddy Oct 27 '17 at 14:40
  • fred -ii- yes i am ask how to make it work, i know i can't get regisrt_no from input field without using javascript because it not possible to get field value without submit the value first. – Abdul Guled Oct 27 '17 at 14:41
  • Ravinder Reddy i don't know AJAX kindly let me know how can i use AJAX retrieve aircraft_type from database based on 'txtregistr_no' input. – Abdul Guled Oct 27 '17 at 14:44
  • http://api.jquery.com/jquery.ajax/ -- It's a little bit of reading, but once you understand it, you'll never have to read it again. Lead a horse to water -->> – Zak Oct 27 '17 at 14:49
  • Your code is vulnerable to [**SQL injection**](https://en.wikipedia.org/wiki/SQL_injection) attacks. You should use prepared statements with bound parameters, via either the [**mysqli**](https://secure.php.net/manual/en/mysqli.prepare.php) or [**PDO**](https://secure.php.net/manual/en/pdo.prepared-statements.php) drivers. [**This post**](https://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php) has some good examples. – Alex Howansky Oct 27 '17 at 15:40

0 Answers0