Verifying Users

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
anthony88guy
Forum Contributor
Posts: 246
Joined: Thu Jan 20, 2005 8:22 pm

Verifying Users

Post by anthony88guy »

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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Whats your criteria for verifying users? As in, surely there's not just a list of users with checkboxes and you just go "Yes, I'll verify you, and you, and you, Oh heck, I'll just verify you all without checking you're ok to verify..." :P What makes a user ok to verify :?:
anthony88guy
Forum Contributor
Posts: 246
Joined: Thu Jan 20, 2005 8:22 pm

Post by anthony88guy »

Well it concerns a game, if you are part of a certain alliance then you may be verified. When you sign up you enter your stats link, so the username will be a link to their stats.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

A simple, untested, way.

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 />");
     }
}

?>
Edit | Updated, Tested.
Last edited by John Cartwright on Fri Apr 08, 2005 4:37 pm, edited 3 times in total.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

I would make the checkbox name a "blank" array and put the values of the usernames in the value attribute.

ex:

Code: Select all

<input type="checkbox" name="users[]" value="<?=$username;?>"><?=$username;?>
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 8O
anthony88guy
Forum Contributor
Posts: 246
Joined: Thu Jan 20, 2005 8:22 pm

Post by anthony88guy »

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.
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

Post by anthony88guy »

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?
Post Reply