php - Redirect with form variable doesn't work properly -
php - Redirect with form variable doesn't work properly -
i have on file (search.php) uses variable received follows:
session_start(); if (isset($_post['search'])){     $_session['search'] = $_post['search']; }    the form:
<form id="searchbox" action="/search.php" method="post">       <input id="search" name="search" type="text" placeholder="search products">    <input id="submit" type="submit" value="search" ></form>    so submits itself
i have next redirects in place:
rewritecond %{the_request} \s/+search\.php? [nc] rewriterule ^ /search/? [r=301,l] rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^search/?$ /search.php? [l,qsa]  rewritecond %{the_request} \s/+search\.php\?pagenum_rs_search=([^\s&]+)&totalrows_rs_search=([^\s&]+) [nc] rewriterule ^ /search/%2/%1? [r=301,l] rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^search/([^/]+)/([^/]+)/?$ /search.php?pagenum_rs_search=$2&totalrows_rs_search=$1 [l,qsa]    which rewrites search.php search/ , paging search/12/1 want do.
the problem when search executed $_post['search'] variable not beingness used. without redirects in place works fine. help welcome
this script paging , search request:
$maxrows_rs_search = 7; $pagenum_rs_search = 0; if (isset($_get['pagenum_rs_search'])) {   $pagenum_rs_search = $_get['pagenum_rs_search']; } $startrow_rs_search = $pagenum_rs_search * $maxrows_rs_search;   $colname_rs_search = "-1"; if (isset($_session['search'])) {   $colname_rs_search = $_session['search']; } mysql_select_db($database_dconn, $dconn); $query_rs_search = sprintf("select * products (category %s or products.manufacturer  %s or products.model  %s or products.color  %s) , category!= 'stage pianos' , category!= 'recent pianos' , category!= 'recent keyboards' , hidden ='no'", getsqlvaluestring("%" . $colname_rs_search . "%", "text"),getsqlvaluestring("%" . $colname_rs_search . "%", "text"),getsqlvaluestring("%" . $colname_rs_search . "%", "text"),getsqlvaluestring("%" . $colname_rs_search . "%", "text"));   $query_limit_rs_search = sprintf("%s limit %d, %d", $query_rs_search, $startrow_rs_search, $maxrows_rs_search); $rs_search = mysql_query($query_limit_rs_search, $dconn) or die(mysql_error()); $row_rs_search = mysql_fetch_assoc($rs_search);  if (isset($_get['totalrows_rs_search'])) {   $totalrows_rs_search = $_get['totalrows_rs_search']; } else {   $all_rs_search = mysql_query($query_rs_search);   $totalrows_rs_search = mysql_num_rows($all_rs_search); } $totalpages_rs_search = ceil($totalrows_rs_search/$maxrows_rs_search)-1;  $querystring_rs_search = ""; if (!empty($_server['query_string'])) {   $params = explode("&", $_server['query_string']);   $newparams = array();   foreach ($params $param) {     if (stristr($param, "pagenum_rs_search") == false &&          stristr($param, "totalrows_rs_search") == false) {       array_push($newparams, $param);     }   }   if (count($newparams) != 0) {     $querystring_rs_search = "&" . htmlentities(implode("&", $newparams));   } } $querystring_rs_search = sprintf("&totalrows_rs_search=%d%s", $totalrows_rs_search, $querystring_rs_search);    paging triggered follows:
<td><?php if ($pagenum_rs_search > 0) { // show if not first page ?>              <a href="<?php printf("%s?pagenum_rs_search=%d%s", $currentpage, 0, $querystring_rs_search); ?>">first</a>              <?php } // show if not first page ?></td>          <td><?php if ($pagenum_rs_search > 0) { // show if not first page ?>              <a href="<?php printf("%s?pagenum_rs_search=%d%s", $currentpage, max(0, $pagenum_rs_search - 1), $querystring_rs_search); ?>">previous</a>              <?php } // show if not first page ?></td>          <td><?php if ($pagenum_rs_search < $totalpages_rs_search) { // show if not  lastly page ?>              <a href="<?php printf("%s?pagenum_rs_search=%d%s", $currentpage, min($totalpages_rs_search, $pagenum_rs_search + 1), $querystring_rs_search); ?>">next</a>              <?php } // show if not  lastly page ?></td>          <td><?php if ($pagenum_rs_search < $totalpages_rs_search) { // show if not  lastly page ?>              <a href="<?php printf("%s?pagenum_rs_search=%d%s", $currentpage, $totalpages_rs_search, $querystring_rs_search); ?>">last</a>                <?php } // show if not  lastly page ?></td>       
when redirect page, loose variable $_post.
you can create php work first , redirect php function header()
 php .htaccess 
 
  
Comments
Post a Comment