This topic is locked

Automatically fill in a textfield

10/7/2005 6:09:14 AM
PHPRunner General questions
OCTheEagle author

I have made a database for educational purpose about toys.
In the database there´s a table called ´production´. To get to the table you have to login with an username and password (created with PHPrunner). In the table there are 4 fields: ProductID (int), name of toy (textfield), creator (textfield) and date made (date).
When you press the add button you have to specify the ProductID, name of the toy, the creator and the date made.
My question: I want the ´creator´ button to be automatically filled with the username. Let´s say you login with the name ´hans´ and you add a page, you only have to fill in the ProductID, name of toy and date made´. The textfield ´creator´ is automatically filled in with the name ´Hans´.
Is there a way of doing that in PHPrunner?

Sergey Kornilov admin 10/10/2005

Hi,
you need to set Default value for Creator field on Formatting tab(Step8) in PHPRunner:
$_SESSION["UserID"]

T
timonsmith 10/24/2005

What is the ASP equivalent of $_Session["variable"]?
I want to add a default value to be a session variable in the formatting pane in ASPRunner Pro.

Sergey Kornilov admin 10/24/2005

In ASP you can use Session("UserID").

R
rhservice 11/29/2005

I need to make this work when an edit is made as well as when new data is entered.
Is this possible. The $_SESSION["UserID"] doesn't seem to work for edits, only when

a new record is added. Or am I missing something? The field is set for Add and Edit

pages both but the user ID is only written to the database table when a new entry is

made but not when an existing entry is edited.

Hi,

you need to set Default value for Creator field on Formatting tab(Step8) in PHPRunner:
$_SESSION["UserID"]

Sergey Kornilov admin 11/30/2005

Hi,
the default values entered in PHPRunner are used when adding records only.

Because when editing a record the initial values are taken from database.
You can modify ..._edit.php file to update the Creator field each time when you edit a record.

Insert the following line :

$evalues["`Creator`"]="'".$_SESSION["UserID"]."'";

just before this snippet:

foreach($evalues as $ekey=>$value)

$strSQL.=$ekey."=".$value.", ";

R
rhservice 11/30/2005

Thank you very much. This works perfectly.
Larry