Jump to content

Recommended Posts

Howdy!

I have a login page that uses a dynamic dropdown list to select the username, the have a cookie created that uses the USERNAME field for the cookie variable. When a user submits the login, it then takes them to a SEARCH page.

I need to know how (or if possible) to have the cookie pre-set the search field with the same name as as the USERNAME field from thje login page.

Here is my code from the login page that creates the cookie:

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST")     {
  setcookie("logIn", "".((isset($_POST["username"]))?$_POST["username"]:"")  ."", time()+(60*60*24*0), "/", "", 0);
}
?>

And this is the code for the SEARCH field from the search page:

<td class="DataTableCell"><input name="S_team" type="text" class="WADADataTableCell" id="S_team" value="<?php echo $_COOKIE['logIn']; ?>" /></td>

 

Is there a way to make this work?

Link to comment
https://forums.phpfreaks.com/topic/85770-use-cookies-to-input-search-text/
Share on other sites

Why use a cookie, why not use the posted name directly? Or if you need the cookie set, do both.

 

Thanks for the idea. How would I use the 'username" to be included on the next page in the search field? ??? (Reading php script is like reading hiroglyphics)  ;)

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.