Form post nie działa

0

Witam! Mam w formularzu pole, gdzie użytkownik wpisuje słowo kluczowe i przycisk, który uruchamia wyszukiwanie. Niestety nijak nie umiem zmusić tego do działania. Jeśli umieszczę kod, odpowiadający za pobieranie danych z pola, na początku skryptu to dane zostaną pobrane do zmiennej, ale nie łapie jej warunek z końca skryptu. Natomiast, jeśli umieszczę kod wczytujący dane do zmiennej na końcu skryptu(razem z ww warunkiem), nie złapie danych z pola..Gdzie tkwi problem? Proszę o pomoc

<div id = mresl>
    <script> jQuery.noConflict(); </script>

<?php 
error_reporting(E_ALL);
JHtml::_('jquery.framework');
JHTML::_('behavior.framework');

$key='';
$yr='';
$sort='';
$parent='';
$selected='';
require_once('/var/www/vhosts/solaris-ustronie.eu/httpdocs/joomla/administrator/modules/mod_activate/db_joomla.php');
include('/var/www/vhosts/solaris-ustronie.eu/httpdocs/joomla/libraries/joomla/user/helper.php');   
   $error="";
jimport( 'joomla.user.user' );
    $user = JFactory::getUser();
          //$parent = $user->name;
           $login = $user->username;
           $id = $user->id;

$query_disp0 = "SELECT * FROM jos_users WHERE id='$id'" ;
    $resultSet0 = mysql_query($query_disp0, $con);
     while($row0 = mysql_fetch_array($resultSet0)) { 

    $name= $row0['name'];
    $surname= $row0['surname'];
    $parent = $row0['parent'];

        if($parent==""){
$parent=$login; 
}
     }
   $user2 = JFactory::getUser($parent);

           $owner_id = $user2->id;

function get_options_y($select, $parent){
    include ('/var/www/vhosts/solaris-ustronie.eu/httpdocs/joomla/administrator/modules/mod_activate/db_joomla.php');
    $y = date("Y");
    $types_y = array(); 
    $index = 1;
    $yr=$y;

    $query_disp = "SELECT * FROM jos_program_reservation WHERE owner = '$parent'";

        $resultSet = mysql_query($query_disp, $con);
 while($row = mysql_fetch_array($resultSet)) { 
     $year =$row['year'];    
$types_y[$year] = $year;
     $index++;

     }

         $options =' ';
         while(list($k, $v)=each($types_y)){

                 if($select==$k){
                 $options.='<option value=" '.$k.' "selected> ' .$v. ' </option>';
             }
             else{
             $options.='<option value=" '.$k.' "> ' .$v. ' </option>';
             }
         }
         return $options;
     }  

Wczytywanie danych z pola:


if(isset ($_POST['subm'])){
$key=$_POST['szukaj'];

//$error = "KEY: ".$key;
if($key==""){

    $error="Musisz podać słowo kluczowe";
}
/*if($key!=""){
    $sort = "Data przyjazdu - od najnowszych";
         $query_disp=$queryS;
        show($query_disp, $sort);*/
    //$error = "KEY: ".$key;
//return $key;

}


```php
?>
<div id="rok"><form method = "post">Wybierz rok: <select class="input_nr" name = "types_y" id="types_y" onchange = "this.form.submit();" > <?php echo get_options_y($selected, $parent); ?> </select></form></div>

<div id = "error_res"><span class="error"><?php echo $error;?></span></div> 

<div id="lista">
<table  name="table" border="1"  style="color:1c4e93; position:relative; top:-279px; border-bottom:none; ">
<thead>

<tr><!--<form method = "post" >-->
<th class = "th"><input type="hidden" name="id" value="id" /><input type="button" value="Lp" name="id_user" class="btn btn-default btn-info" onClick="location.href='https://www.solaris-ustronie.eu/joomla/administrator/modules/mod_activate/reservations_sort.php?param=id"></th>

<th class = "th"><input type="hidden" name="type" value="type" /><input type="button" value="Nazwisko" name="un" class="btn btn-default btn-info" style="width: 222px;" onClick="location.href='https://www.solaris-ustronie.eu/joomla/administrator/modules/mod_activate/reservations_sort.php?param=name'"></th>

<th class = "th"><input type="hidden" name="nm" value="n" /><input type="submit" value="Imię" name="usr" class="btn btn-default btn-info" style="width: 222px;" onClick="location.href='https://www.solaris-ustronie.eu/joomla/administrator/modules/mod_activate/reservations_sort.php?param=surname'"></th>

<th class = "th"><input type="hidden" name="tl" value="tl" /><input type="submit" value="Telefon" name="utl" class="btn btn-default btn-info" style="width: 222px;" onClick="location.href='https://www.solaris-ustronie.eu/joomla/administrator/modules/mod_activate/reservations_sort.php?param=telefon'"></th>

<th class = "th"><input type="hidden" name="e" value="e" /><input type="submit" value="Email" name="uml" class="btn btn-default btn-info" style="width: 222px;" onClick="location.href='https://www.solaris-ustronie.eu/joomla/administrator/modules/mod_activate/reservations_sort.php?param=surname'"></th>

<th class = "th"><input type="hidden" name="range" value="da" /><input type="button" value="Data przyjazdu" name="uda" class="btn btn-default btn-info" style="width: 222px;" onClick="location.href='https://www.solaris-ustronie.eu/joomla/administrator/modules/mod_activate/reservations_sort.php?param=email"></th>

<th class = "th"><input type="hidden" name="d1" value="d1" /><input type="button" value="Data wyjazdu" name="ud1" class="btn btn-default btn-info" style="width: 222px;" onClick="location.href='https://www.solaris-ustronie.eu/joomla/administrator/modules/mod_activate/reservations_sort.php?param=date_dep"></th>

<th class = "th"><input type="hidden" name="cf" value="cf" /><input type="button" value="Potwierdzone" name="uconf" class="btn btn-default btn-info" style="width: 60px;" ></th>

<th class = "th"><input type="hidden" name="add" value="add" /><input type="button" value="Dodał(a)" name="uadd" class="btn btn-default btn-info" style="width: 222px;" ></th>

    <th class = "th" width="120px;"><div style = "width: 120px;">Opcje</div></th>
</tr>
</thead>
<tbody>

<?php 

function show($query_disp, $sort){

    include ('/var/www/vhosts/solaris-ustronie.eu/httpdocs/joomla/administrator/modules/mod_activate/db_joomla.php');
    /*   $user = JFactory::getUser();
    $id = $user->id;
    $query_disp="SELECT * FROM jos_program_prices WHERE id_owner= '$id'";   */

    //$query_d=$query_disp;
    $resultSet = mysql_query($query_disp, $con);
     $table ="jos_program_reservation";
     $id_col="id";
    $lp=0;
?>

Pole do podawania słów kluczowych:

<div id="search"><form method = "post"><p><input class="input_sz" type="text" name = "szukaj" id="szukaj" placeholder="Szukaj..."  ></input><input class="search_btn" type="submit" name="subm" value=" "></p></form><span id="sicon" class="icon-search large-icon"></span></div>
    <div id="sort_res"> 
<form method = "post">
<p>Sortuj po: <select name="order" class="input_nr" id="order" style="width: 230px !important" onchange="<?php //show($query_disp) ?>">
<option value="sort"><?php echo $sort; ?></option>
<option value="6" onClick="location.href='https://www.solaris-ustronie.eu/joomla/administrator/modules/mod_activate/reservation__sort.php?param=6'">Nazwisko A-Z</option>
<option value="7" onClick="location.href='https://www.solaris-ustronie.eu/joomla/administrator/modules/mod_activate/reservation__sort.php?param=7'">Nazwisko Z-A</option>
<option value="8" onClick="location.href='https://www.solaris-ustronie.eu/joomla/administrator/modules/mod_activate/reservation__sort.php?param=8'">Imię A-Z</option>
<option value="9" onClick="location.href='https://www.solaris-ustronie.eu/joomla/administrator/modules/mod_activate/reservation__sort.php?param=9'">Imię Z-A</option>
<option value="10" onClick="location.href='https://www.solaris-ustronie.eu/joomla/administrator/modules/mod_activate/reservation__sort.php?param=10'">Telefon rosnąco</option>
<option value="11" onClick="location.href='https://www.solaris-ustronie.eu/joomla/administrator/modules/mod_activate/reservation__sort.php?param=11'">Telefon malejąco</option>
<option value="12" onClick="location.href='https://www.solaris-ustronie.eu/joomla/administrator/modules/mod_activate/reservation__sort.php?param=12'">Email A-Z</option>
<option value="13" onClick="location.href='https://www.solaris-ustronie.eu/joomla/administrator/modules/mod_activate/reservation__sort.php?param=13'">Email Z-A</option>
<option value="0" onClick="location.href='https://www.solaris-ustronie.eu/joomla/administrator/modules/mod_activate/reservation__sort.php?param=0'">Data przyjazdu - od najnowszych</option>
<option value="3" onClick="location.href='https://www.solaris-ustronie.eu/joomla/administrator/modules/mod_activate/reservation__sort.php?param=3'">Data przyjazdu - od najstarszuch</option>
<option value="5" onClick="location.href='https://www.solaris-ustronie.eu/joomla/administrator/modules/mod_activate/reservation__sort.php?param=5'">Data wyjazdu - od najnowszych</option>
<option value="4" onClick="location.href='https://www.solaris-ustronie.eu/joomla/administrator/modules/mod_activate/reservation__sort.php?param=4'">Data wyjazdu - od najstarszych</option>
<option value="14" onClick="location.href='https://www.solaris-ustronie.eu/joomla/administrator/modules/mod_activate/reservation__sort.php?param=14'">Dodane przez A-Z</option>
<option value="15" onClick="location.href='https://www.solaris-ustronie.eu/joomla/administrator/modules/mod_activate/reservation__sort.php?param=15'">Dodane przez Z-A</option>
</select></p></form></div>  

    <?php

     while($row = mysql_fetch_array($resultSet)) { 

    $lp++;

    ?>

        <tr>
        <form method = "POST"><p>
<td class="container_res" width = "40px;"><center><?php  echo $lp;?></td>
<td class="container_res" ><center><div><input type="submit" class="preview" name="name" size="40;" line-height="0px" value="<?php  echo $row['name'];?>"></input></div></td>   
<td class="container_res"><center><div class="td_div"><input type="submit" class="preview" name="surname" size="40" line-height="0px" value="<?php echo $row['surname'];?>"></input></div></td>
<td class="container_res"><center><div><input type="submit" class="preview" name="phone" size="40" line-height="0px" value="<?php echo $row['phone'];?>"></input></div></td>
<td class="container_res"><center><div><input type="submit" class="preview" name="email" size="40" line-height="0px" value="<?php echo $row['email'];?>"></input></div></td>
<td class="container_res"><center><div><input type="submit" class="preview" name="date_a" size="40" line-height="0px" value="<?php echo $row['date_ar'];?>"></input></div></td>
<td class="container_res"><center><div><input type="submit"class="preview"  name="date_d" size="40" line-height="0px" value="<?php echo $row['date_dep'];?>"></input></div></td>
<td class="container_res"><center><div><input type="submit" class="preview" name="ad_by" size="40" line-height="0px" value="<?php echo $row['added_by'];?>"></input></div></td>
        </p></form>

        <td class="container_res">
    <div> <input type="hidden" name="id" value="<?php echo $id; ?> " /></div>
   <div><input type="hidden" name="table" value="<?php echo $table; ?> " /></div>
<div class="opt_btnu"> <input type="button" value="Usuń"  class="btn btn-primary" style="width: 58px;" onClick="location.href='https://www.solaris-ustronie.eu/joomla/administrator/modules/mod_activate/delete_reservation.php?param=<?php echo $table;?>,<?php echo $id_col;?>,<?php echo $id;?>'"></div>
        </td>
   </tr>

<?php   } mysql_close();}

$year="";

if(isset ($_POST['types_y'])){
$selected = $_POST['types_y'];
$year = $selected;  
$yr = $year;
}
if(!isset ($_POST['types_y'])){
$y = date("Y");
$year = $y;
$yr = $y;   
}

Warunek:


$queryS = "SELECT * FROM jos_program_reservation WHERE owner ='$parent' AND (name='$key' OR surname='$key' OR phone='$key' OR email = '$key' OR added_by='$key') ORDER BY date_ar DESC";

if($key!=""){
$error = "KEY: ".$key;
$sort = "Data przyjazdu - od najnowszych";
$query_disp=$queryS;
show($query_disp, $sort);

}

```php
$query0="SELECT * FROM jos_program_reservation WHERE owner= '$parent' AND year = '$year' ORDER BY date_ar DESC";    

           $query3 = "SELECT * FROM jos_program_reservation WHERE owner = '$parent' AND year = '$year' ORDER BY date_ar ASC";
       $query4 = "SELECT * FROM jos_program_reservation WHERE owner = '$parent' AND year = '$year' ORDER BY date_dep ASC";
       $query5 = "SELECT * FROM jos_program_reservation WHERE owner = '$parent' AND year = '$year' ORDER BY date_dep DESC";
       $query6 = "SELECT * FROM jos_program_reservation WHERE owner = '$parent' AND year = '$year' ORDER BY name ASC";
         $query7 = "SELECT * FROM jos_program_reservation WHERE owner = '$parent' AND year = '$year' ORDER BY name DESC";
          $query8 = "SELECT * FROM jos_program_reservation WHERE owner = '$parent' AND year = '$year' ORDER BY surname ASC";
        $query9 = "SELECT * FROM jos_program_reservation WHERE owner = '$parent' AND year = '$year' ORDER BY surname DESC";
        $query10 = "SELECT * FROM jos_program_reservation WHERE owner = '$parent' AND year = '$year' ORDER BY phone ASC";
        $query11 = "SELECT * FROM jos_program_reservation WHERE owner = '$parent' AND year = '$year' ORDER BY phone DESC";
       $query12 = "SELECT * FROM jos_program_reservation WHERE  owner = '$parent' AND year = '$year' ORDER BY email ASC";
         $query13 = "SELECT * FROM jos_program_reservation WHERE owner = '$parent' AND year = '$year' ORDER BY email DESC";
          $query14 = "SELECT * FROM jos_program_reservation WHERE  owner = '$parent' AND year = '$year' ORDER BY added_by ASC";
         $query15 = "SELECT * FROM jos_program_reservation WHERE owner = '$parent' AND year = '$year' ORDER BY added_by DESC";

if(isset ($_GET['query']))

{ 

$query=$_GET['query'];

    if($query=='query3'){
        $sort = "Data przyjazdu - od najastarszych";
        $query_disp=$query3;
         show($query_disp, $sort);
    }       
        if($query=='query4'){
        $sort = "Data wyjazdu - od najstarszych";
        $query_disp=$query4;
             show($query_disp, $sort);
    }   
           if($query=='query5'){
        $sort = "Data wyjazdu - od najnowszych";
        $query_disp=$query5;
             show($query_disp, $sort);
    }   
           if($query=='query6'){
        $sort = "Nazwisko A-Z";
        $query_disp=$query6;
             show($query_disp, $sort);
    }   
           if($query=='query7'){
        $sort = "Nazwisko Z-A";
        $query_disp=$query7;
             show($query_disp, $sort);
    }   
           if($query=='query8'){
        $sort = "Imię A-Z";
        $query_disp=$query8;
             show($query_disp, $sort);
    }   

    if($query=='query9' )
        {
        $sort = "Imię Z-A";
            $query_disp=$query9;
         show($query_disp, $sort);
        }
    if($query=='query10'){

        $sort = "Telefon rosnąco";
        $query_disp=$query10;
         show($query_disp, $sort);
    }   
    if($query=='query11'){

        $sort = "Telefon malejąco";
        $query_disp=$query11;
         show($query_disp, $sort);
    }       
        if($query=='query12'){

        $sort = "Email A-Z";
        $query_disp=$query12;
             show($query_disp, $sort);
    }       
        if($query=='query13'){

            $sort = "Email Z-A";
        $query_disp=$query13;
             show($query_disp, $sort);
    }   
      if($query=='query14'){

            $sort = "Dodane przez A-Z";
        $query_disp=$query14;
             show($query_disp, $sort);
    }   
    if($query=='query14'){

            $sort = "Dodane przez Z-A";
        $query_disp=$query14;
             show($query_disp, $sort);
    }   
}                   
         else
         {
             $sort = "Data przyjazdu - od najnowszych";
             $query_disp=$query0;
            show($query_disp, $sort);
         }

 ?>
  </tbody>
</table>
</div>
</div>
0

U mnie form post działa.

0

Hmm hmm hmm... Tak jak napisali przedmówcy, najlepiej będzie ten kod podzielić. Dużo łatwiej będzie Ci to zabezpieczyć i połapać się w nim po jakimś czasie. Problem jest w tym że masz skomplikowany skrypt którego jak obstawiam nie rozumiesz i próbujesz kombinować tak długo aż zadziała. To zła droga. A jeśli chodzi o te znikające zmienne to prawdopodobnie ten js sobie nie radzi.

1 użytkowników online, w tym zalogowanych: 0, gości: 1, botów: 0