php - search using 3 options with hidden input type do not work -


i have search page allow user search other members using 3 types

  • governorate
  • district
  • village

and using 1 form , 1 button 3 types 3 different hidden values

but problem system not make action when select governorate

so can me ????

code:

<?php //**********search locationn***************************************// if(isset($_post['listbyq'])) {     //********************by governorate**************************************//    if($_post['listbyq']=="by_gov")    {        $bygov = $_post['governorate'];        $sql = mysql_query("select user_id,first_name, last_name, birth_date, registered_date, governorate_name                          members u inner join  governorate g                          on u.governorate = g.governorate_id governorate = '$bygov'")or die(mysql_error("error: querying governorate"));         $num_row = mysql_num_rows($sql);        if($num_row > 0 )        {            while($row = mysql_fetch_array($sql))            {               $row_id = $row['user_id'];               $row_first_name =  $row['first_name'];               $row_last_name =  $row['last_name'];               $row_birthdate =  $row['birth_date'];               $row_registered_date = $row['registered_date'];               $row_gov = $row['governorate_name'];                  ////***********for upload image*************************//          $check_pic="members/$row_id/image01.jpg";          $default_pic="members/0/image01.jpg";          if(file_exists($check_pic))          {              $user_pic="<img src=\"$check_pic\"width=\"120px\"/>";          }          else          {              $user_pic="<img src=\"$default_pic\"width=\"120px\"/>";          }            $outputlist.='      <table width="100%">                  <tr>                     <td width="23%" rowspan="4"><div style="height:120px;overflow:hidden;"><a href =              "http://localhost/newadamkhoury/profile.php?user_id='.$row_id.'" target="_blank">'.$user_pic.'</a></div></td>                     <td width="14%"><div  align="right">name:</div></td>                     <td width="63%"><a href = "http://localhost/newadamkhoury/profile.php?user_id='.$row_id.'" target="_blank">'.$row_first_name.' '.$row_last_name.'</a></td>                     </tr>                      <tr>                       <td><div align="right">birth date:</div></td>                       <td>'.$row_birthdate.'</td>                     </tr>                     <tr>                      <td><div align="right">registered:</div></td>                      <td>'.$row_registered_date.'</td>                     </tr>                      <tr>                      <td><div align="right">governorate</div></td>                      <td>'.$row_gov.'</td>                     </tr>                     </table>                     <hr />             ';             }        }     } } else {     $errormsg = "no member has listed location!!"; }  ?> 

html code

  <table width="94%" height="63">                 <tr>                   <td width="29%"><form id="form1" method="post" action="member_search2.php">                    <h3>search location</h3><br />                   <?php require_once('location_fields.php'); ?>                     <input type="hidden" name="listbyq" value="by_gov" />                     <input type="hidden" name="listbyq" value="by_dist" />                     <input type="hidden" name="listbyq" value="by_city" />                     <input type="submit" name="searchbylocation" id="button" value="go" />                   </form></td> </tr> </table> 

this because assigning same name input field name="listbyq", change name different among them can retrieve in different variables

<input type="hidden" name="listbyq" value="by_gov" /> <input type="hidden" name="listbyqa" value="by_dist" /> <input type="hidden" name="listbyqb" value="by_city" /> 

now can use them respectively in if statements

 if($_post['listbyq'] == 'by_gov')  if($_post['listbyqa'] == 'by_dist')  if($_post['listbyqb'] == 'by_city') 

then remember mysql_ functions deprecated advise switch mysqli or pdo , indeed @ risk of sql injection, have here how can prevent sql injection in php?. should use prepared statment avoid risk


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -