Jump to content

[SOLVED] Help Please


mike1313

Recommended Posts

I've written a simple chatroom for my website. But I want to know how I can make it so if the user types a certain command, that a certain table in the MySql DB can be updated and it doesnt display anything on the page. For example if they wanted to change the color of their font in the chat, they would type /hexcode #FFFFFF

 

and it would find them in the db and under the field chatfont it would change it to #FFFFFF, I know everything about updating the DB and so forth all I need is what I should use for the line of code to check to see if they posted at least /hexcode and it gets rid of /hexcode and just updates the db with #FFFFFF all help is appreciated thanks.

Link to comment
https://forums.phpfreaks.com/topic/43321-solved-help-please/
Share on other sites

How about this:

 

$command = trim(urldecode($_POST['command']));
if (strpos($command, '/hexcode') === 0) {
  # We found /hexcode at offset 0
  $colour = preg_replace('|/hexcode *|', '', $command);
  # Then update the db with $colour
}

 

There's many other ways to do it.. if you have many commands to detect, you may want to start by checking if '/' is at the start, and only then parsing the command.

Link to comment
https://forums.phpfreaks.com/topic/43321-solved-help-please/#findComment-210360
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.