Jump to content

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
Link to comment
https://forums.phpfreaks.com/topic/16027-short-problem/
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]
Link to comment
https://forums.phpfreaks.com/topic/16027-short-problem/#findComment-65907
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.
Link to comment
https://forums.phpfreaks.com/topic/16027-short-problem/#findComment-65910
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.


Link to comment
https://forums.phpfreaks.com/topic/16027-short-problem/#findComment-65916
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.