php - SQL shown no record after submit INSERT -


when submit sql query there no record created in database, no error message displayed.

** sorry long code because don't know problem code , have basic knowledge in programming.

i using 2 different tables query , insert:

<?php      if(isset($send))     {         $today=date('y-m-d');          $fname=isset ($_post['fname']) ? $_post['fname'] : '';         $fname=mysqli_real_escape_string($con, $fname);          $sql=mysqli_query("select * kc54i_workforce_employees fname='$fname'");         $row=mysqli_fetch_array($sql);         $namestaff=$row['lname'];          $sql2 = "         insert `avenue`.`staff_movement` (`id`, `staff_no`, `department`, `name`, `status`, `category`, `datestart`, `dateeng`)         values (null, '$fname','$department','$namestaff','$status','$category','$datestart','$dateend');";          if(@mysqli_query($con, $sql2))         {             echo "<script type='text/javascript'>\n";             echo "alert('new record created successfully');\n";             echo "window.navigate('add_move_test.php');";             echo "</script>";         }         else             echo "error: " . $sql2 . "<br>" . mysqli_error();     }     else   ?> 
<html> <body>   <form name="add_move_test.php" action="<?php $_server['php_self'] ?>" method="post" onsubmit="return formcheck(this);">     <table>       <tr>       <tr>         <td valign="top">department</td>         <td valign="top">           <select name="department" onchange='this.form.submit();'>              <?php $department=isset($_post[ 'department']) ? $_post[ 'department'] : '';                    $department=mysqli_real_escape_string($con, $department); ?>              <option value="">-select one-</option>             <option value="7" <?php if ($department=="7" ) echo "selected";?>>management</option>             <option value="2" <?php if ($department=="2" ) echo "selected";?>>administration</option>             <option value="5" <?php if ($department=="5" ) echo "selected";?>>human resource</option>             <option value="25" <?php if ($department=="25" ) echo "selected";?>>business development</option>             <option value="12" <?php if ($department=="12" ) echo "selected";?>>finance</option>             <option value="19" <?php if ($department=="19" ) echo "selected";?>>procurement</option>             <option value="1" <?php if ($department=="1" ) echo "selected";?>>it support</option>             <option value="6" <?php if ($department=="6" ) echo "selected";?>>project</option>             <option value="13" <?php if ($department=="13" ) echo "selected";?>>project(control)</option>             <option value="10" <?php if ($department=="10" ) echo "selected";?>>project(management)</option>             <option value="8" <?php if ($department=="8" ) echo "selected";?>>project(transportation)</option>             <option value="24" <?php if ($department=="24" ) echo "selected";?>>construction</option>             <option value="16" <?php if ($department=="16" ) echo "selected";?>>construction(management)</option>             <option value="4" <?php if ($department=="4" ) echo "selected";?>>construction(planning & cost estimation)</option>             <option value="18" <?php if ($department=="18" ) echo "selected";?>>engineering</option>             <option value="15" <?php if ($department=="15" ) echo "selected";?>>engineering(civil)</option>             <option value="14" <?php if ($department=="14" ) echo "selected";?>>engineering(fire & gas)</option>             <option value="23" <?php if ($department=="23" ) echo "selected";?>>engineering(electrical)</option>             <option value="22" <?php if ($department=="22" ) echo "selected";?>>engineering(instrument)</option>             <option value="3" <?php if ($department=="3" ) echo "selected";?>>engineering(mechanical)</option>             <option value="9" <?php if ($department=="9" ) echo "selected";?>>engineering(layout & piping)</option>             <option value="20" <?php if ($department=="20" ) echo "selected";?>>engineering(process)</option>             <option value="17" <?php if ($department=="17" ) echo "selected";?>>hsse</option>             <option value="11" <?php if ($department=="11" ) echo "selected";?>>quality(qa/qc)</option>           </select>         </td>       </tr>       <tr>         <td valign="top">name</td>         <td valign="top">           <select name="fname">             <option selected>-select name-</option>              <?php $sql="select * kc54i_workforce_employees department='$department' order lname asc" ;                    $results=mysqli_query($con, $sql);                    while ($row=mysqli_fetch_array($results)) {                        $department=$row[ 'department'];                    $name=$row[ 'lname']; $fname=$row['fname']; ?>             <option value="<?php echo $fname;?>">                            <?php echo $name;?>             </option>             <?php               }              ?>           </select>         </td>       </tr>       <tr>         <td valign="top">category</td>         <td valign="top">           <select name="category">             <?php $category=i sset($_post[ 'category']) ? $_post[ 'category'] : ''; $category=mysqli_real_escape_string($con, $category); ?>             <option value="">-select one-</option>             <option value="office" <?php if ($category=="office" ) echo "selected";?>>office</option>             <option value="site" <?php if ($category=="site" ) echo "selected";?>>site</option>           </select>         </td>       </tr>       <tr>         <td valign="top">date start</td>         <td valign="top">           <script>             dateinput('datestart', true)           </script>         </td>       </tr>       <tr>         <td valign="top">date end</td>         <td valign="top">           <script>             dateinput('dateend', true)           </script>         </td>       </tr>       <tr>         <td valign="top">status</td>         <td valign="top">           <input name="status" type="text" id="status" size="50" maxlength="50">         </td>       </tr>       <tr align="center" valign="middle">         <td colspan="2">           <input name="send" type="submit" id="send" value="send">           <input name="clear" type="reset" id="clear" value="clear">           <input type="button" name="back" value="back" onclick="javascript:history.back();">         </td>       </tr>     </table>   </form> </body> </html> 

there space in between isset function things there,i run because don't have table structure of yours,

 <html>     <body>       <form name="add_move_test.php" action="<?php $_server['php_self'] ?>" method="post" onsubmit="return formcheck(this);">         <table>           <tr>           <tr>             <td valign="top">department</td>             <td valign="top">               <select name="department" onchange='this.form.submit();'>                  <?php                  $department=isset($_post[ 'department']) ? $_post[ 'department'] : '';                  $department=mysqli_real_escape_string($con, $department); ?>                  <option value="">-select one-</option>                 <option value="7" <?php if ($department=="7" ) echo "selected";?>>management</option>                 <option value="2" <?php if ($department=="2" ) echo "selected";?>>administration</option>                 <option value="5" <?php if ($department=="5" ) echo "selected";?>>human resource</option>                 <option value="25" <?php if ($department=="25" ) echo "selected";?>>business development</option>                 <option value="12" <?php if ($department=="12" ) echo "selected";?>>finance</option>                 <option value="19" <?php if ($department=="19" ) echo "selected";?>>procurement</option>                 <option value="1" <?php if ($department=="1" ) echo "selected";?>>it support</option>                 <option value="6" <?php if ($department=="6" ) echo "selected";?>>project</option>                 <option value="13" <?php if ($department=="13" ) echo "selected";?>>project(control)</option>                 <option value="10" <?php if ($department=="10" ) echo "selected";?>>project(management)</option>                 <option value="8" <?php if ($department=="8" ) echo "selected";?>>project(transportation)</option>                 <option value="24" <?php if ($department=="24" ) echo "selected";?>>construction</option>                 <option value="16" <?php if ($department=="16" ) echo "selected";?>>construction(management)</option>                 <option value="4" <?php if ($department=="4" ) echo "selected";?>>construction(planning & cost estimation)</option>                 <option value="18" <?php if ($department=="18" ) echo "selected";?>>engineering</option>                 <option value="15" <?php if ($department=="15" ) echo "selected";?>>engineering(civil)</option>                 <option value="14" <?php if ($department=="14" ) echo "selected";?>>engineering(fire & gas)</option>                 <option value="23" <?php if ($department=="23" ) echo "selected";?>>engineering(electrical)</option>                 <option value="22" <?php if ($department=="22" ) echo "selected";?>>engineering(instrument)</option>                 <option value="3" <?php if ($department=="3" ) echo "selected";?>>engineering(mechanical)</option>                 <option value="9" <?php if ($department=="9" ) echo "selected";?>>engineering(layout & piping)</option>                 <option value="20" <?php if ($department=="20" ) echo "selected";?>>engineering(process)</option>                 <option value="17" <?php if ($department=="17" ) echo "selected";?>>hsse</option>                 <option value="11" <?php if ($department=="11" ) echo "selected";?>>quality(qa/qc)</option>               </select>             </td>           </tr>           <tr>             <td valign="top">name</td>             <td valign="top">               <select name="fname">                 <option selected>-select name-</option>                  <?php $sql="select * kc54i_workforce_employees department='$department' order lname asc" ;                        $results=mysqli_query($con, $sql);                        while ($row=mysqli_fetch_array($results)) {                           $department=$row[ 'department'];                        $name=$row[ 'lname']; $fname=$row['fname']; ?>                 <option value="<?php echo $fname;?>">                                <?php echo $name;?>                 </option>                 <?php                   }                  ?>               </select>             </td>           </tr>           <tr>             <td valign="top">category</td>             <td valign="top">               <select name="category">                 <?php $category=isset($_post[ 'category']) ? $_post[ 'category'] : ''; $category=mysqli_real_escape_string($con, $category); ?>                 <option value="">-select one-</option>                 <option value="office" <?php if ($category=="office" ) echo "selected";?>>office</option>                 <option value="site" <?php if ($category=="site" ) echo "selected";?>>site</option>               </select>             </td>           </tr>           <tr>             <td valign="top">date start</td>             <td valign="top">               <script>                 dateinput('datestart', true)               </script>             </td>           </tr>           <tr>             <td valign="top">date end</td>             <td valign="top">               <script>                 dateinput('dateend', true)               </script>             </td>           </tr>           <tr>             <td valign="top">status</td>             <td valign="top">               <input name="status" type="text" id="status" size="50" maxlength="50">             </td>           </tr>           <tr align="center" valign="middle">             <td colspan="2">               <input name="send" type="submit" id="send" value="send">               <input name="clear" type="reset" id="clear" value="clear">               <input type="button" name="back" value="back" onclick="javascript:history.back();">             </td>           </tr>         </table>       </form>     </body>     </html> 

Comments