to what I am programming because the number of web functions will be
increasing --- it isn't a set number. I have never worked with arrays before.
Is there another way to define the array? I am storing information about
these functions in a table and I could run a query to find out how many there
are and what their values are and populate the array this way. What I really
want to do is to take the results of the form --- which boxes are checked in
and compare them with a user permissions table I have designed and then make
the table match the form which was just submitted with a series of DELETE,
UPDATE and INSERT commands. There is a second field in this I haven't
mentioned yet --- a performance review date associated with those who have
been given access to each function.
Ron
Ron,
One option is to build a list of privs and iterate over that for the form
and processing
To do that, you would iterate over the list and use variables to name the
fields. When you process the form, you would iterate over the same list and
extract the values.
The functions that have these permissions can be stored in a table and just
retrieved thru a loop. To create your matrix structure of permissions and
functions, you loop thru the permissions as you loop thru the fuctions data
set
the above code would create a table row with the function name, then a
series of checkboxes with the value of the checkbox being the index element
of the array and a name of perm_ and the function name and the name of the
permission to be able to relate the permissions back to the function name
Does this help?
Bastien
>From: "ron.php"
>To: ghammar@certifiedparts.com
>CC: php-db@lists.php.net
>Subject: [PHP-DB] Processing web forms
>Date: Sun, 16 Apr 2006 07:29:51 -0400
>
>
>I am not sure how to apply the
>
>array ('priv1', 'priv2', 'priv3' ...);
>
>to what I am programming because the number of web functions will be
>increasing --- it isn't a set number. I have never worked with arrays
>before.
>
>Is there another way to define the array? I am storing information about
>these functions in a table and I could run a query to find out how many
>there
>are and what their values are and populate the array this way. What I
>really
>want to do is to take the results of the form --- which boxes are checked
>in
>and compare them with a user permissions table I have designed and then
>make
>the table match the form which was just submitted with a series of DELETE,
>UPDATE and INSERT commands. There is a second field in this I haven't
>mentioned yet --- a performance review date associated with those who have
>been given access to each function.
>
>Ron
>
>
>Ron,
>
>One option is to build a list of privs and iterate over that for the form
>and processing
>
>To do that, you would iterate over the list and use variables to name the
>fields. When you process the form, you would iterate over the same list and
>extract the values.
>
>Form building:
>
>$foo = array ('priv1', 'priv2', 'priv3' ...);
>...
>foreach ($foo as $priv) {
> ...
>
>$priv; ?>
> ...
>}
>
>Form processing:
>
>foreach ($foo as $priv) {
> if (isset($_POST[$priv])) {
> do something here like update the database or build one SQL
>statement
> }
>}
>
>Instead of using a list when you build foo, you could use a hash.
>
>$foo = array('priv1' => 'Man readable priv 1', 'priv2' => 'Man readable
>priv
>2', 'priv3' => 'Man readable priv 3' ...);
>...
>foreach (array_keys($foo) as $priv) {
> ...
>
>$foo[$priv]; ?>
> ...
>}
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
RE: Processing web forms
am 16.04.2006 16:02:09 von Ron Piggott
Good morning Bastien
This doesn't help. I am having no problems creating the form of what the
current permissions are based on the permission access table. I am not sure
what to do with the form once it has been submitted.
I am able to create the table which shows each permission function and what
the current values are. Take a look at the name= fields; "Discipleship &
Follow Up" is a category, the 2 functions being granted permission are the
Christian Ministry & Business Directory Administration and the Verse of the
Day Administration.
Discipleship & Follow Up
type="checkbox" name="3" checked="checked">
Christian Ministry and Business Directory Administration
My problem is that I am not sure how to find out the value of $3 and
$performance_review_3 when the form has been submitted. The reason I am
having problems is because the # changes --- it is 3 and 1 in the above
example.
What I want to do is a SELECT * using the logged in user's reference number
as the searching criteria ... then take a look at what was just submitted and
then see if there is a difference. If there is a difference make what was
submitted through the form (above) reality.
I am going to query the table that generated the form (above) --- it knows
how many components there are and then I could use a
$i=0;
WHILE $i < $number_of_permissions {
++$i;
}
What troubles me is that $i isn't $3 and I am not sure how to retrieve the
value of $3 when $i isn't the same variable name.
Ron
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
RE: Processing web forms
am 16.04.2006 20:05:21 von Bastien Koert
Ah i getcha.
Checkboxes only have a few options as values (On, or a value that you give
it (like 1). Personally I tend to use (esp for items like permissions that
are either on or off) a value of 1. Then if its 1, I know that the box was
checked and that is what the user wants to have.
$3 = $_POST['3']; would be the way to access that element
Now if you are using a db to create the form in the first place, you can use
that same call to loop thru the post array, instead of echoing it out.
Is that clearer?
Bastien
>From: "ron.php"
>To: bastien_k@hotmail.com
>CC: php-db@lists.php.net
>Subject: RE: [PHP-DB] Processing web forms
>Date: Sun, 16 Apr 2006 10:02:09 -0400
>
>
>Good morning Bastien
>
>This doesn't help. I am having no problems creating the form of what the
>current permissions are based on the permission access table. I am not
>sure
>what to do with the form once it has been submitted.
>
>I am able to create the table which shows each permission function and what
>the current values are. Take a look at the name= fields; "Discipleship &
>Follow Up" is a category, the 2 functions being granted permission are the
>Christian Ministry & Business Directory Administration and the Verse of the
>Day Administration.
>
>
Discipleship & Follow Up
>
>type="checkbox" name="3" checked="checked">
>Christian Ministry and Business Directory Administration
>
>My problem is that I am not sure how to find out the value of $3 and
>$performance_review_3 when the form has been submitted. The reason I am
>having problems is because the # changes --- it is 3 and 1 in the above
>example.
>
>What I want to do is a SELECT * using the logged in user's reference number
>as the searching criteria ... then take a look at what was just submitted
>and
>then see if there is a difference. If there is a difference make what was
>submitted through the form (above) reality.
>
>I am going to query the table that generated the form (above) --- it knows
>how many components there are and then I could use a
>
>
>$i=0;
>WHILE $i < $number_of_permissions {
>
>
>++$i;
>}
>
>What troubles me is that $i isn't $3 and I am not sure how to retrieve the
>value of $3 when $i isn't the same variable name.
>
>Ron
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
RE: Processing web forms
am 16.04.2006 20:58:58 von Ron Piggott
Thanks Bastien. It works now. Amazing. I am understanding the $_POST[]
command. Thanks for your help. Ron
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php