Jump to content

Archived

This topic is now archived and is closed to further replies.

xyn

Short problem

Recommended Posts

Hi guys.
I have got a small problem, I want to make a "Time Block" for my user management,
Where Moderators / Admins can Block(ban) a member for a certain time.
How ever I thought using Cookies would fail easily.
Using MYSQL i don't have a clue. The only way i can do with SQL
is a date(); although if the date & time was changed it would unban them...

Basically does anyone have any ideas how I can make a time Ban script
for my members area?

Thanks!
- Ash

Share this post


Link to post
Share on other sites
This is only a quick example but your get the drift good luck.

ban a user via there id.

add a date field and name field user_id field.

add a link to the admin page like this

example only.

The link

[code]
<?php  session_start();

$date=date("d-m-y");
$user_id=$_SESSION['user_id']=$row['user_id'];
$members_name=$_SESSION['member_name']=$row['member_name'];
$user_ban="yes";

<a href="user_band.php?user_id=$user_id&date_band=$date&members_name=$members_name&user_ban='yes'&band_user=user_band">Baned this user</a>

[/code]

user_band.php
[code]
<?php session_start();

$date=($_POST['date']);
$user_id($_POST['user_id']);
$members_name=($_POST['members_name']);
$user_ban=($_POST['user_ban']);

$date=stripslashes($date);
$user_id=stripslasses($user_id);
$members_name=stripslashes($members_name);
$user_ban=stripslashes($user_ban);

if($_GET['band_user']==user_band){

$insert_query="INSERT INTO band_user(user_id,date,members_name,user_ban)VALUES('$user_id','$date','$members_name','user_ban')";
$insert_result=mysql_query($insert_query);

$select_user="SELECT * form user_ban where user_id='$user_id";
$select_user=mysql_query($select_user);

while($record=mysql_fetch_assoc($select_user)) {

elseif($record['user_id']==1) {

$query="UPDATE band_user set user_id='$user_id' AND date='$date' AND members_name='$members_name' AND user_ban='$user_ban' WHERE user_id=$user_id";

$result=mysql_query($result);

header("location:admin.php");
}
}
  }
?>
[/code]

Share this post


Link to post
Share on other sites
That's pretty confusing Lol. I've not come accross some of that before :/.
I'll see what I can do with it but I don't really understand it.

I don't see how that would ban someone for "2 hours, 24 hours, 1 month etc."
And Is there something that can be placed in a form.

Share this post


Link to post
Share on other sites
afther all that burning my fingers off

do you know how to use session or got sessions inplemented

Share this post


Link to post
Share on other sites
The above code was using a link so you dont need to use a form.

In the admin page you should of had a page with all the users accounts and had links to delete the user ect ect ect

that where my code comes in.

The first thing was to get all the information to ban a user then insert the users deatails then if that user exists update the user_ban tables that the only way i know sorry.

afther you get all the correct information then we do the date syntex ok.

we would of selected the database and tables then see if the user date was today if so ban them but if they come tommorw let them do whatever.

but it tales a lot of coding sorry.


Share this post


Link to post
Share on other sites
Yeah I know it uses $_GET function, I wanted to be able to set a time, ie X hours, days, Months.
X - my number :/

Share this post


Link to post
Share on other sites
how can we do that with a form method when you need a link on the admin pannel.

or your have millins of forms for every member to ban that silly.

Share this post


Link to post
Share on other sites
your have to look up

strtotime();

floor();

date();

time();

ok sorry.

Share this post


Link to post
Share on other sites
Nope. Using your kind of way or we could use a drop-down.
then use $_POST and submit it that way.

Banning by User ID through Hidden Fields.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.