FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Form help

 


Relentless
Hi,
I have an input box. I also have a pop-up window. Is it posible to have some text or a button in the pop up button and when pressed the text auto-matically enteres into my input box?

To see what I mean please Click Here. Goto Clients area (top right)

Then you will see my input box...

Click on the forgot your username?(top right)

I want the clients to be able to click that username and it to inport to the input box...

Cheers Dan...
CTMiB
The easiest way I can think of is to use a session variable to store the username. You have to start a session when the user first opens the page:

Code:
<?php session_start(); ?>


In the entry form, you want the textbox to reference the session variable as its initial value.

Code:
<input type="text" name="username" value="<?php $_SESSION['user']; ?>">


The buttons in the pop-up window can call a function to store the appropriate value in the session variable ($_SESSION['user']), then close the pop-up window, and reload the form.

Unfortunately, my php skills are still fairly novice in nature, so the code snippets that I gave are probably very wrong, but you should be able to get the general idea from it.

Oh, and be sure to include a session_destroy() call somewhere after the submit button is pressed, so the variables are cleared.

Hope this helps!
rvec
instead of this:
<?php $_SESSION['user']; ?>
use this:
<?php echo $_SESSION['user']; ?>

and be sure to give it a value like this:
<?php $_SESSION['user'] = "Rvec"; ?>

or if the nick already is a var:
<?php $_SESSION['user'] = $var; ?>

but if you need to use the nick on only one page there is no need to use sessions. You can just use the var multiple times. So if the code of the pop-up is not on another page you can use the same var again.
CTMiB
Yeah, the reason that I suggested a session variable was because it was for a username, which I would expect to appear on multiple pages, much like the "Welcome" message at the top of the forum page here.
Relentless
Hey guys...

Cheers for your replys...

TBA its not a big deal. its just something i could try to do really. If you looked at the pages you should have seen what i was on about...

and even tho you gave me this code I am only just getting into PHP and not know yet how to code it into my form or username pop-up...

Thanks for your replys...

Dan....
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.