Chat commands to script

Hi

i wanna add commands for mods and admins to my chat script just the basic ones

/ban username message minutes

/unban username

how would i do this with a image as theres no info on google

<?php
session_start();
//including the database connection file
require_once("../../include/config.php");
// Please Do not touch this //

  //Create select query
  $query = "SELECT * FROM chat LEFT JOIN `users` ON users.id = chat.username  where chat.id ORDER BY chat.id  ASC";
  $shouts = mysqli_query($link,$query);
  
?>

<?php

  //Check if form is submitted
  if(isset($_POST['submit']))
  {
    $username = mysqli_real_escape_string($link, $_POST['username']);
    $message = mysqli_real_escape_string($link, $_POST['message']);

    //Set timezone
    date_default_timezone_set('Australia/Adelaide');
        $Published = date("Y-m-d H:i:s");
    
    //Validate input
    if(!isset($username) || $username=='' || !isset($message) || $message=='')
    {
      $error = "Please fill in your name and a message";
      header("Location: index.php?error=".urlencode($error));
    }
    else
    {
      $query = "INSERT into chat (username,message,Published)
            VALUES ('$username','$message','$Published')";
      if(!mysqli_query($link, $query))
      {
        die("Error: ".mysqli_error($link));
      }
      else
      {
        header("Location: dashboard.php");
        exit();
      }
    }
  }


?>

 <?php while($rowe = mysqli_fetch_assoc($shouts)) : ?>
<div class="row">
  <div class="col-sm-3">
  <?php 
if(empty($rowe['image'])){
   $avatar = 'http://www.gravatar.com/avatar/' . md5( $rowe['email'] ) . '?s=33&d=wavatar&r=g';
    echo '<img src="' . $avatar . '" />';
 }else{
    echo '    <img src="'. $rowe['image'] .' "  style="width:23%" alt="Circle Image" class="rounded-circle"/> </img>';
    }
       ?>
   <?php  
    if ($rowe['role'] === "admin") {
echo '<span class="badge badge-danger"> '. $rowe['username'] .' </span> <a  href="' . $row['siteurl'] . 'pages/profile.php?id=' . $rowe['id'] . '/' . $rowe['username'] .'.php"><i class="fas fa-user-shield"></a></i>
</br><h6 style="color:#f12100;font-weight: 1000;background-color: #160e19;padding: 4  1px;border-radius: 1px;text-transform: uppercase;background-image: none;text-shadow: 1px 1px 1px rgb(65, 25, 41);"> '. $rowe['role'] .' </h2></br>'; 

}elseif ($rowe ['role'] ===  "Mod") {
echo '<span class="badge badge-dark" style="color:'. $rowe['css'] .');">'. $rowe['username'] .'</span> <a  href="' . $row['siteurl'] . 'pages/profile.php?id=' . $rowe['id'] . '/' . $rowe['username'] .'.php"><i class="fas fa-gavel"></a></i>
</br> <h6 style="color: #0d27de;font-weight: 1000;background-color: #14d0be;padding: 4  1px;border-radius: 1px;text-transform: uppercase;background-image: none;text-shadow: 1px 1px 1px rgb(65, 25, 41);">'. $rowe['role'] .'</h2></br>';

}elseif ($rowe ['role'] ===  "user") {
echo '<span class="badge badge-light" style="color:'. $rowe['css'] .');">'. $rowe['username'] .' </span> <a  href="' . $row['siteurl'] . 'pages/profile.php?id=' . $rowe['id'] . '/' . $rowe['username'] .'.php"><i class="fas fa-user"></a></i>
</br> <h6 style="color:#b1b2bd;font-weight: 1000;background-color: #1e5204a6;padding: 5  1px;border-radius: 1px;text-transform: uppercase;background-image: none;text-shadow: 1px 1px 1px rgb(65, 25, 41);">'. $rowe['role'] .'</h2></br>';
 } 
?> 

  </div></br></br></br></br></br>
  <div class="col-md-6">
    
</br>
    <button class="btn btn-info" style="height:80px;width:310px"> </strong>  <?php echo $rowe['message'] ?> </button> 
</br>
  </div>
  <div class="col-sm-3"><i class="fas fa-calendar"></i>  <?php echo date('Y/m/d' , strtotime($rowe['Published']));?>  </br> 


    <i class="fas fa-clock"></i>  <?php echo date('h:i A' , strtotime($rowe['Published']));?> 
</div>    
</div>
        <?php endwhile; ?>

this is the form that i use to chat

<form  method="post" action="chat.php">
   <input type="text" name="username" readonly hidden placeholder="Enter your name" value="<?php echo $_SESSION['id'];?>">
<div class="input-group mb-3">
  <input type="text" name="message" class="form-control" placeholder="Enter Your Message">

  <div class="input-group-append">
  <button class="btn btn-info" type="submit"  name="submit" value="Send!">Send Message</button>
  </div>
</div>
    <span class="input-group-btn">
   </span>
   </form>

add an elseif to your if statement to catch the target keywords at the beginning of the message.

ok so how would i go about it?

as theres gifthub chat scripts but they either outdated lol

https://www.php.net/manual/en/control-structures.elseif.php

Ok then

i think i wont worrying about adding this command i will pay someone down the. road as i am not good with php not a pro just learning

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.