FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

PHP/(X)HTML Help

 


codeman
I've been playing with php and xhtml for some time now... but I still haven't come up with a way to do this:

Lets say I have a bunch of people sign up for my website... for whatever reason...

they all end up in a db and I have it set up so that they have to be approved first. I want to display all of the new members on one page and be able to approve or deny then and then if approved set the column in the db to reflect that or delete the unapproved individuals but I don't know how I would go about that... and I'm not even sure how to explain what about that I don't get... so if you someone knows what I'm talking about please explain otherwise please ask me questions to make it clearer to you what it is I'm after... I know it can be done, I'm just not sure of all the inner workings


also I've been successful at creating a system where it would display one at a time but I'd have to approve/deny one person at a time and it was rather annoying

Thanks,
Codeman
snowboardalliance
(mods: this should be moved to php)

Ok you'll need to use a mysql database

Basically you have a register page
It shows all the fields to fill out, and it will look at any input, if it is valid (all fields filled in, any other checks) then add this user in a simple mysql query. This usertable will have a column, "approved" as boolean and default to false.

Now on your admin page. YOu will need a login system. This can be done many ways, from more complex and secure, to simple cookies or sessions. Anyway, you basically need to check the username password combination with your user database.

Once you have a login system, you will need the page to approve users. This should be something where either only user ID 1 (needs to be you) can access it, or have an admin (boolean) column on the user table and make sure the user is an admin.

The approve page should just get all users, and pretty much put it all in a table. The approved users should be marked, and unapproved will have two links like (approve.php?yes=1111 and approve.php?no=1111) where 1111 is the user id. Now this page should check, if "yes" is set, it should update that userid to approved = true, and if "no" is set it will delete the row where userid=whatever id was passed in.

Ok, I don't know if you wanted actual code or more help, but I think that should point you in the right direction, although it's very brief and I might not have explained anything. I can go into detail on certain areas if your interested, but don't have the time to write it for you.

Good luck.
ganbate
i think you must ask in the php thread, because most of the job is in the php side.

thinks that you should do:
1. make a database which contain username, pass, and the key that can sign approved or non approved user.
2. connect your form to insert the user data into the database.
3. view the have'nt been approved user by selecting the user which the key value is 0 (1 is approved user for example).
4. edit the key value to 1 to approve the user or delete the entry if you don't want to approve the user.

you can use phpmyadmin to manage the database, or you can make your own code in php to insert, delete, view, and edit the database.
codeman
I have everything but the admin thing done already... I just need to know how to code the admin page so that I can select the people I want to approve and submit that group to be updated in the db. I have the db set up the the registration page made login system... as I said I've been working on this for a while the only thing that illudes me is how to set up that page... thanks tho Very Happy


PS Also, I asked here because I'm more confused on the (x)html part of it than the php part of it... php is easy... I'm just confused as to how to let php know what needs to do what... anyway I guess I failed to mention that... sry
snowboardalliance
OK, umm the html part isn't hard. I use a templating system (smarty), but if you're just outputting html it would be somethign like

(in a loop of mysql results)
Code:

<table>
   <tr>
      <td>username</td>
      <td>userid</td>
      <td>approve</td>
      <td>deny</td>
   </tr>
<!-- loop starts here -->
   <tr>
      <td>$row['username']</td>
      <td>$row['userid']</td>
      <td><a href="THIS.php?approve=$row['userid']"> approve</a></td>
      <td><a href="THIS.php?deny=$row['userid']"> deny</a></td>
   </tr>
<!-- ends here -->
</table>


The loop should be done after you have the results of a SELECT of your user table.

Code:
while ($row = mysql_fetch_assoc($result)) {
//here
}


I think this should help. You may need to modify variable names and you can do variable sustitution in php however you like.

The php code I think you understand but again its like

Code:
if (isset($_GET['approve']))
{
// code here to set approve to true where the userid is $_GET['approve']
}
elseif (isset($_GET['deny']))
{
// code here to delete where userid is $_GET['deny']
}


Oh, one more thing, you might want that userlist up there (the html) to come from a sql query that has "WHERE approve = 0" so it only shows unapproved users. Good luck.
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.