Jump to content

Refreshing SESSION variable with an HTML form


ArizonaJohn

Recommended Posts

Hello,

 

I have the following HTML form at the top of a page called tsearch18.php.  This page uses the variable "find" as a session variable.  I would like the value of "find" to remain constant unless the user hits the submit button on the form below (or of course types a new value into the form and hits enter). 

 

So, I would like to trigger "unset($_SESSION['find']);" whenever the HTML form is used.  But only then.  How can I do this?

 

I am having a hard time figuring out where to put "unset($_SESSION['find']);"  I tried an if statement and it didn't work.

 

Thanks in advance,

 

John

 

 

<div class="searchbox">
  <form action="tsearch18.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>
  </div>

Hi Waynewex,

 

That code does what I want... but I only want it to do that if the "Search" button is clicked.

 

And then after the "Search" button is clicked, I want to re-set the session variable and keep it live.

 

So far I can't get it to work.

Hi Waynewex,

 

Almost there... this is a little weird, but it works if the HTML form is used twice.

 

So when I hit enter, the result is whatever had been entered into the search bar one attempt previously.

 

Any ideas why it is doing that?

 

Thanks

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.