Hello,
On my site, a user enters a value into a form, and if that value is not in my database, the code below is meant to give the user the message "The topic "value" has not been added. Add the topic "value"." When I pull up my site in Firefox and enter in a non-existent value for the first time, the message says "The topic "" has not been added. Add the topic ""." Then if I enter in a second non-existent value, it works correctly.
When I pull up my site in Google Chrome and enter in a non-existent value for the first time, the message is populated with the last non-existent value that I had previously looked up before closing the tab. Then the second time I look up another non-existent value, everything is fine.
So somehow, the first time I use the code below after loading the site in a browser, the session variable $find is not getting pushed through to the end, but the second time I use the code it all works fine. Can anyone see any reason why?
Thanks
My index page has this:
Then search.php has this:
Then search2.php has this:
On my site, a user enters a value into a form, and if that value is not in my database, the code below is meant to give the user the message "The topic "value" has not been added. Add the topic "value"." When I pull up my site in Firefox and enter in a non-existent value for the first time, the message says "The topic "" has not been added. Add the topic ""." Then if I enter in a second non-existent value, it works correctly.
When I pull up my site in Google Chrome and enter in a non-existent value for the first time, the message is populated with the last non-existent value that I had previously looked up before closing the tab. Then the second time I look up another non-existent value, everything is fine.
So somehow, the first time I use the code below after loading the site in a browser, the session variable $find is not getting pushed through to the end, but the second time I use the code it all works fine. Can anyone see any reason why?
Thanks
My index page has this:
Code:
<?php session_start(); unset($_SESSION['find']); ?> <form action="search.php" method="post"> <label>Enter Topic: <input type="text" name="find" size="55"/> <input type="hidden" name="searching" value="yes" /> <input type="submit" name="search" value="Search" /> </label> </form>
Code:
<?php ob_start(); session_start(); unset($_SESSION['find']); $find = strip_tags($_POST['find']); $find = trim ($find); $find = strtolower($find); $_SESSION['find'] = $find; ?> $anymatches=mysql_num_rows($result); if ($anymatches == 0) { $_SESSION['find'] = $find; header("Location:search2.php"); exit; }
Code:
<?php session_start(); $_SESSION['find'] = $find; ?> print "<p class=\"topic2\">The topic \"$find\" has not been added.</p>\n"; print "<p class=\"topic2\">Add the topic \"$find\".</p>\n";
Comment