justAnoob Posted June 13, 2009 Share Posted June 13, 2009 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 More sharing options...
justAnoob Posted June 13, 2009 Author Share Posted June 13, 2009 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 More sharing options...
trq Posted June 14, 2009 Share Posted June 14, 2009 And how exactly are you directing users back to this same page? Link to comment Share on other sites More sharing options...
justAnoob Posted June 14, 2009 Author Share Posted June 14, 2009 the form where the number is inputed is on the homepage. so if the user hits the back button on their browser or if they hit the home button on any of the pages, it takes them back and the error is still there. Link to comment Share on other sites More sharing options...
trq Posted June 14, 2009 Share Posted June 14, 2009 The back button will of course take them back to the last page they visited, query string and all still intact. Your home button however should simply point to / Link to comment Share on other sites More sharing options...
justAnoob Posted June 14, 2009 Author Share Posted June 14, 2009 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 More sharing options...
Recommended Posts