Gossamer Forum
Home : Products : DBMan SQL : Discussion :

admin_form.html dropdown

Quote Reply
admin_form.html dropdown
In my admin_form.html template, how do I create a dropdown list of users from the user list? The default html template for admin is very difficult to use.
Thanks,

David
Quote Reply
Re: [davidbessler] admin_form.html dropdown In reply to
You can create a global template called list_users to handle it:

sub {
my $tags = GT::Template->tags;
my $home = $tags->{home};
my $sth = $home->{sql}->table($home->{cfg}->{'user_table_use'})->select();
my @output;
while ( my $rs = $sth->fetchrow_hashref ) {
push @output, $rs;
}

return { loop_users => \@output };
}

And then update the admin_form.html:
<%list_users%>
<select name="a_Username">
<%loop loop_users%>
<option value="<%Username%>"><%Username%></option>
<%endloop%>
</select>

Hope that helps.

TheStone.

B.
Quote Reply
Re: [604] admin_form.html dropdown In reply to
trying to get this to work. i can lookup and select a user and it correctly displays the user info. but it puts the first username back in the lookup box so when i click update/create user it gives an error message. my username has admin permission and is the first name in the list, so i don't know if it's putting the first username or my username. errors vary - sometimes says username must be unique, sometimes email must be unique, sometimes passwords don't match. I added the line in blue or the select box didn't do anything. since it looks up the user correctly, i think my problem is in the admin form:
Code:
<%include header.html%>
<center>
<form name='myform' action='db.cgi' method=post>
<%ifnot use_cookie%><input type=hidden name="sid" value=<%session_id%>><%endif%>
<input type=hidden name=db value="<%db%>">
<input type=hidden name=do value="admin_action">
<input type=hidden name="users" value="<%if a_Username%><%a_Username%><%endif%>">
<input type=hidden name="a_Tablename" value="<%db%>">

<%if sdb%>
<!--Subform-->
<input type=hidden name="sdb" value="<%sdb%>">
<input type=hidden name="sdo" value="<%if sdo%><%sdo%><%endif%>">
<input type=hidden name="sfk" value="<%if sfk%><%sfk%><%endif%>">
<%endif%>

<%if q%>
<!--Query objects-->
<input type=hidden name="q" value="<%q%>">
<%endif%>
<table border=1 bgcolor="#FFFFFF" cellpadding=0 cellspacing=0 width="500" valign=top>
<tr><td>
<table border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="163" align="right"><font face="Arial, Helvetica, sans-serif" size="2">User Name: </font></td>
<td width="337">
<%list_users%>
<select name="a_Username">
<%loop loop_users%>
<option value="<%Username%>"><%Username%></option>
<%endloop%>
</select>
<input type="submit" name="admin_action" value="Find User">
<input type="submit" name="sub_delete" value="Delete" onclick="if (document.myform.users.selectedIndex == 0) {return false;} if (!confirm('Do you want to Delete this user?')) return false;">
</td>
</tr>
<tr>
<td width="163" align="right"><font face="Arial, Helvetica, sans-serif" size="2">New
User Name: </font></td>
<td width="337">
<input type="text" name="user" size="25">
</td>
</tr>
<tr>
<td width="163" align="right"><font face="Arial, Helvetica, sans-serif" size="2">Change Password: </font></td>
<td width="337">
<input type="Password" name="a_Password" size="25" value="<%if a_Password%><%a_Password%><%endif%>">
</td>
</tr>
<tr>
<td width="163" align="right"><font face="Arial, Helvetica, sans-serif" size="2">Confirm password: </font></td>
<td width="337">
<input type="Password" name="password_confirm" size="25" value="<%if password_confirm%><%password_confirm%><%else%><%if Password%><%Password%><%endif%><%endif%>">
</td>
</tr>
<tr>
<td width="163" align="right" ><font face="Arial, Helvetica, sans-serif" size="2">Email: </font></td>
<td width="337" >
<input type="text" name="a_Email" size="25" value="<%if a_Email%><%a_Email%><%endif%>">
</td>
</tr>
<tr>
<td width="163" align="right" ><font face="Arial, Helvetica, sans-serif" size="2">Name: </font></td>
<td width="337" >
<input type="text" name="a_Name" size="25" value="<%if a_Name%><% a_Name%><%endif%>">
</td>
</tr>
<tr>
<td width="163" align="right" ><font face="Arial, Helvetica, sans-serif" size="2">Status: </font></td>
<td width="337" > <select name="a_Status">
<option value="Administrator" <%if a_Status eq 'Administrator'%>selected<%endif%>>Administrator
<option value="Not Validated" <%if a_Status eq 'Not Validated'%>selected<%endif%>>Not Validated
<option value="Registered" <%if a_Status eq 'Registered'%>selected<%endif%>>Registered</select>
</td>
</tr>
<tr>
<td width="163" align="right" ><font face="Arial, Helvetica, sans-serif" size="2">Receive Mail: </font></td>
<td width="337" > <select name="a_ReceiveMail">
<option value="No" <%if a_ReceiveMail eq 'No'%>selected<%endif%>>No
<option value="Yes" <%if a_ReceiveMail eq 'Yes'%>selected<%endif%>>Yes</select>
</td>
</tr>
<tr>
<td width="163" align="right" ><font face="Arial, Helvetica, sans-serif" size="2">News letter: </font></td>
<td width="337" > <select name="a_Newsletter">
<option value="No" <%if a_Newsletter eq 'No'%>selected<%endif%>>No
<option value="Yes" <%if a_Newsletter eq 'Yes'%>selected<%endif%>>Yes</select>
</td>
</tr>
I DELETED THE PERMISSION SECTION TO SAVE ROOM HERE
</table>
</td>
</tr>
</table>
<b><font face="Arial, Helvetica, sans-serif" size="2"> </font></b>
</td>
</tr>
</table>
<br>
<table width="500" border="1" cellspacing="0" cellpadding="0">
<tr>
<td height="40">
<div align="center">
<input type="submit" name="sub_edit" value=" Update/Create User ">
</div>
</td>
</tr>
</table>
</form>
</center>
<p><%include footer.html%>
Quote Reply
Re: [delicia] admin_form.html dropdown In reply to
What are you trying to do? Load a list of the users, and have it selected based on the username that was last passed in?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] admin_form.html dropdown In reply to
yes. i'm trying to go from dbman to dbman sql.

my admin form in dbman had a drop down list to select a user with a button next to it. until you selected a user from the list, the name, password, email etc were blank. once you selected someone and clicked the inquire button, it displayed that user's info. you could modify the info and click update/create button to update the info. or you could ignore the dropdown list, type a username in the NewUsername field, enter info and click the update/create button to create a new user.

the admin form in sql always has my username in the drop list and my info on the screen. don't know if it's because i have lowest number and therefore am first in the file or if it's because i'm the one logged in. the only way to pull up someone else's info in default admin form is to type in their username in a text field. once you tab out of the text field it pulls up their info. i want to get rid of that technique and do it like old dbman.

dbman sql also has a Name field in the user table. i don't want to use this field at all. instead i want to look up the real name (Firstname and Lastname fields) in my members table. see my other post in this forum!

thanks!

Last edited by:

delicia: Jul 25, 2010, 5:32 AM
Quote Reply
Re: [delicia] admin_form.html dropdown In reply to
Hi,

Mmm ok - not sure I can really be of much help with this, as I don't have a copy of DBManSQL installed (I think I have a copy somewhere, but can't find it)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!