Jump to content

[SOLVED] Php (Meta Refresh) Redirection Issue !!


nita

Recommended Posts

Hi

I'm building little script (movie collection).

 

The issue is that when:

-there is no results - browser is showing a communicate and redirecting back to the root (index.php) after 2 sec

-input is less then 2 char - browser is  showing a communicate and redirecting back to the root (index.php) after 2 sec

 

search part of the application --

 

else if(isset($_POST['submit'])||isset($_POST['search'])) // when search button is pressed
{
echo "
<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'
'http://www.w3.org/TR/html4/loose.dtd'>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
<LINK REL='StyleSheet' href='movies.css' TYPE='text/css'>
<title>Nita Movies</title>
</head>
<body>
<table width='950'>
<tr>
<td bgcolor='#663300' width='180' border='0' cellspacing='0' cellpadding='0'  valign='top' class='font2' >";
$result = mysql_query("SELECT * FROM category ORDER BY cat") or die(mysql_error());
while($row = mysql_fetch_array( $result )) 
{

echo "<A href='index.php?cat=$row[cat]'>$row[cat]</a><br>";
}
echo "	
<br>
<form method='post' action='$php_self'>
<input type='text' name='search' size=25 maxlength=25 minleneght=2><br>
<input type='Submit' name='Submit' value='Submit'>
</form>
</td>

<td class='font2'>";

$PHP_SELF = $_SERVER['PHP_SELF'];

$search=$_POST["search"];

$minchar = 2;
if (strlen($search) < $minchar)
{
    echo "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'
			'http://www.w3.org/TR/html4/loose.dtd'>
			<html>
			<head>
			<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
			<META HTTP-EQUIV='REFRESH' CONTENT='2; URL=$PHP_SELF'>
			<LINK REL='StyleSheet' href='movies.css' TYPE='text/css'>
			<title>Nita Movies</title>
			</head>
			<body>";

	echo "Search must be longer than 2 characters.
	</body>
	</html>
";
} 
else 
{
    $result = mysql_query("SELECT * FROM movies WHERE name LIKE '%$search%' 
    OR cast LIKE '%$search%' OR director LIKE '%$search%' 
    OR year LIKE '%$search%' OR production LIKE '%$search%'
    OR genere LIKE '%$search%' OR language LIKE '%$search%'");

    $numrows=mysql_num_rows($result);
    if ($numrows == 0)
  	    {
  	          echo "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'
			'http://www.w3.org/TR/html4/loose.dtd'>
			<html>
			<head>
			<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
			<META HTTP-EQUIV='REFRESH' CONTENT='2; URL=$PHP_SELF'>
			<LINK REL='StyleSheet' href='movies.css' TYPE='text/css'>
			<title>Nita Movies</title>
			</head>
			<body>";
		echo "<p>Sorry, your search returned 0 results</p>
		</body>
		</html>
";

  	    }
    else 
    { 
        while($row=mysql_fetch_array($result))
        {	
       	        include "display_rec.php";
        }
    }
}
	echo "
</td>
</tr>
</table>
</body>
</html>
";

}

 

For example when i.m browsing one of the categories and then do search resulting in these communicates.

Browser is redirecting me to the root of the apllication, what i want to be done, is that browser will redirect me to the place i started my search from.

 

to see what i mean exactly go to:

www.nita-on-line.com/movies/

browse one of the categories and apply search like "a" or some other leading to not receive any results.

 

in my opinion (and from some advice i get before most important lines to look at is

 

$PHP_SELF = $_SERVER['PHP_SELF'];

and

<META HTTP-EQUIV='REFRESH' CONTENT='2; URL=$PHP_SELF'>

 

if some one can help me to find a solution for that one.

im happy to publish entire code of the apllication (its not too long) if you think that my help to solve a problem.

 

Thanks a lot in advance

Nita

 

Hi

 

How should i configure refresh url so browser will refresh page and will be back to the point before search has been done.

<META HTTP-EQUIV='REFRESH' CONTENT='2; URL=$PHP_SELF'>

 

to use some variables after $Php_Self

 

anyways, is it possible at all, i think it is, just i don't know how to code it.??

 

any solution?

 

Thanks. Nita

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.