mysql - PHP : Undefined index while updating record -


i trying edit , update record . view.php going edit.php

<a href="edit.php?edit=<?php echo $u_id;?>">edit</a> 

and on edit.php code

<?php     $connect= mysqli_connect('localhost', 'root', '');     $db= mysqli_select_db($connect, 'students');      $edit= $_get['edit'];     $query= "select * u_reg u_id=".$edit;       $result= mysqli_query($connect, $query);     if(!$result){         die(mysqli_errno($connect));     }      while ($row = mysqli_fetch_array($result)) {         $id= $row['u_id'];         $sname= $row['u_name'];         $fathername=$row['u_father'];         $school=$row['u_school'];         $rollno= $row['u_roll'];                 $class=$row['u_class'];    ?>       <html>         <head>             <title>title</title>         </head>         <body>             <form method="post" action="edit.php?editform=<?php echo $id;?>">                 <table width="500" align="center" >                     <tr>                         <th bgcolor="yellow" colspan="5" >updating students record </th>                     </tr>                     <tr>                         <td>student name</td>                         <td>                             <input type="text"  name="user_name1" value="<?php echo $sname;?>">                          </td>                                             </tr>                         <tr>                         <td>father name</td>                         <td>                             <input type="text" name="father_name1" value="<?php echo $fathername;?>">                          </td>                                             </tr>                     <tr>                         <td>school name</td>                         <td>                             <input type="text" name="school_name1" value="<?php echo $school;?>">                          </td>                                             </tr>                     <tr>                         <td>roll no</td>                         <td>                             <input type="text" name="roll_no1" value=" <?php echo $rollno;?>">                                                  </td>                                              </tr>                     <tr>                         <td>class</td>                         <td>                             <select name="student_class1">                                 <option value="10">10</option>                                 <option  value="<?php echo $class;?>"><?php echo $class;?></option>                                 <option value="11">11</option>                             </select>                                                 </td>                                             </tr>                     <tr>                         <td align="center" colspan="6"><input type="submit" name="update" value="submit"></td>                      </tr>                 </table>              </form>             <?php };?>         </body>     </html>      <?php          if(isset($_post['update'])){             $edit_record1= $_get['editform'];             $s_name= $_post['user_name1'];             $f_name= $_post['father_name1'];             $sc_name= $_post['school_name1'];             $r_no = $_post['roll_no1'];             $cl_name= $_post['student_class1'];              $query1="update u_get set u_name='$s_name' , u_father='$f_name', u_school='$sc_name' , u_roll='$r_no' , "                     . "u_class='$cl_name' u_id=".$edit_record1;                     if(mysqli_query($connect, $query1)){                 echo 'record updated';             }          }              ?> 

i able populate records in fields against records click edit when try update error

notice: undefined index: edit in c:\wamp\www\students\edit.php on line 5

please me

notice: undefined index: edit in c:\wamp\www\students\edit.php on line 5

i guess line 5 code $edit= $_get['edit'];

you know why you're getting error? it's because form method type post , how catch parameters in $_get? think.

your form type:

 <form method="post" action="edit.php?editform=<?php echo $id;?>"> 

php code @ top catch edit parameter

 $edit= $_get['edit']; 

the solution is, should change method type get, , parameters using $_get not $_post.


Comments