I have a small login membership area and only want certain viewers allowed to access the infomation. So if your a administrator of my site, i want you to be able to verify signed up users that arnt verified. How should i go about doing this? I was thinking about having a checkbox and you click that then it will verify all the users that have the check box checked. i.e
$username "check box"
$username "check box"
$username "check box"
$username "check box"
$username "check box"
$username "check box"
$username "check box"
|Submit|
Something like that, using foreach loops to display all the usernames and checkboxes.
Verifying Users
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
-
anthony88guy
- Forum Contributor
- Posts: 246
- Joined: Thu Jan 20, 2005 8:22 pm
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
A simple, untested, way.
Edit | Updated, Tested.
Code: Select all
<?php
$user = array('user1','user2','user3','user4','user5');
echo '<form action="" method="POST">';
foreach ($user as $newuser) {
echo '<input type="checkbox" name="users['.$newuser.']" value="checked"> '. $newuser .'<br />';
}
echo '<input name="" type="submit">
</form>';
if (!empty($_POST))
{
foreach ($_POST['users'] as $user => $value)
{
mysql_query("UPDATE `users` SET `verified` = 1 WHERE `username` = '".$user."' LIMIT 1 <br />");
}
}
?>
Last edited by John Cartwright on Fri Apr 08, 2005 4:37 pm, edited 3 times in total.
I would make the checkbox name a "blank" array and put the values of the usernames in the value attribute.
ex:
then use your foreach loop to loop over the values to "confirm" them.
I've never seen it done the way Jcart suggested, but that doesn't mean much...It probably works as well
ex:
Code: Select all
<input type="checkbox" name="users[]" value="<?=$username;?>"><?=$username;?>I've never seen it done the way Jcart suggested, but that doesn't mean much...It probably works as well
-
anthony88guy
- Forum Contributor
- Posts: 246
- Joined: Thu Jan 20, 2005 8:22 pm
I am having trouble with the following code:
When i try and access the page, it never loads. It tries to but get caught somwhere.
Never Mind, i played around with the code, and now it works.
When i try and access the page, it never loads. It tries to but get caught somwhere.
Never Mind, i played around with the code, and now it works.
Last edited by anthony88guy on Thu May 12, 2005 5:48 pm, edited 1 time in total.
-
anthony88guy
- Forum Contributor
- Posts: 246
- Joined: Thu Jan 20, 2005 8:22 pm
Sorry for the double post but it different questions then before. I have my code that displayes the users and the info i need to display in order to verify them. But now how do i actully verify them?
So i each user that is checked and when the form is submited then it should for each user update the status feild in the table to "1". I noticed Jcarts script their but how would i tie that in?
So i each user that is checked and when the form is submited then it should for each user update the status feild in the table to "1". I noticed Jcarts script their but how would i tie that in?