Jump to content

Short problem


xyn

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

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

Archived

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

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