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>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.