0 Users appreciate this thread.
how to make commands like in chats
angelrulez7 (2014-06-01 05:51:47)Upgrade to mysqli so that all your work isn't ruined if your host updates the PHP version.
a
Log in to submit a comment
Back to forum: Web Programming (HTML, JS, CSS, PHP, MySQL)
New registered users today: 7
Newest registered user: ElegantVulpes
ill assume you already have chat. I prefer ajax with the chat.
so what you do is decide what your code is gonna be. then decide how its gonna operate (Example: /ban PLMasterSSB 2 day)
then you get the variable of your text box in the chat: $text
then your gonna use the substr() and explode() function:
<?php
if(substr($text, 0, 4) == "/ban"
$substrvari = substr($text, 5);
// checks if there is text starting from the 5th character
$explode = explode(" ", $substrvari);
// explodes every set of words starting from the 5th character
//name the variables now
// PLMasterSSB
$explode2 = $explode[0];
// interger
$explode3 = $explode[1];
// time measure
$explode4 = $explode[2];
// but then if you were gonna do the ban command like above you need to use the NOW() and DATE_ADD function
MySQL_query("UPDATE register SET banneduntil=DATE_ADD(banneduntil, INTERVAL interger TimeMeasure) WHERE username='PLMasterSSB'"
// but actually you replace the "interger" and "TimeMeasure" with the variables $explode3 for "interger" and $explode4 for "TimeMeasure"
MySQL_query("UPDATE register SET banneduntil=DATE_ADD(banneduntil, INTERVAL $explode3 $explode4) WHERE username='PLMasterSSB'"
}
?>
I know I probably didn't explain this good but the part about the substr() and explode() is the part you really need to know.
^ Click
(This Image was created from cooltext.com)