Jump to content

variable in header question


justAnoob

Recommended Posts

I have these two lines below, both on separate php files. the varaible works great. the problem i am having is if there is a match it takes me to a certain page, then when I go back a page, i still have the echoed variable. i guess the question is after the script runs and the variable is echoed, i want to get rid of it so when i go back to that page it is gone.

 

header("location: http://www.-------.com/-------.php?no_match=No item found.");

 

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

{

  $no_matches = $_GET['no_match'];

  echo $no_matches;

}

else

{

  echo "";

}

Link to comment
Share on other sites

let me explain this better. i have a form which i enter a number in. if there is a match to that number in my database, it takes me to another page, Great, thats what i want.

if there is not a match to the number entered in, an error message is displayed, great also.

 

so right now, the error message is being displayed, so, i enter another number in, and it is a match to a number in the database, and again, it takes me to that page. 

 

here is problem... now when i go back to the first page where i enter in the numbers, i still have that error being displayed from the previous entry that did not have a match. How do I get rid of that when I go back to the page. the code is above, i am using a variable sent thru the url to display the message.

Link to comment
Share on other sites

Okay, now I'm trying something different. I'll use a SESSION which displays a message. I have done this a hundred times before, but for some reason, it will not work this time. And yes, session start is at the top of both pages, form page and the script page. also, i'm just showing what is important for each script. my session message is not showing. what is going on? Also, I keep getting the error on the bottom of my browser, "done, but errors on page." i have this at the top of the page

error_reporting(E_ALL);

ini_set('display_errors',1);

but no errors come up.

 

script

<?php
if($count != 1)
{
   $_SESSION['noresult'] = "No item found.";
   header("location: http://www.-------.com/-----.php");
   exit();  
   // i know the if and else work, cause instead of the session and header i could just put an echo, and the echo works just fine.
}   
?>

 

form page

<?php
if(isset($_SESSION['noresult']))
{
   echo $_SESSION['noresult'];
}
?>

Link to comment
Share on other sites

Guest
This topic is now 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.