Hack Forums
[PHP] How would i make this chat system escape chars? - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Web Development (https://hackforums.net/forumdisplay.php?fid=183)
+---- Thread: [PHP] How would i make this chat system escape chars? (/showthread.php?tid=5776831)



How would i make this chat system escape chars? - JAS - Dec 30, 2017

Did this myself by running the posts through another file that cleaned them. Thanks


RE: How would i make this chat system escape chars? - Charger - Dec 30, 2017

Give this stackoverflow answer a read:
https://stackoverflow.com/a/31714103


RE: How would i make this chat system escape chars? - JAS - Dec 30, 2017

(Dec 30, 2017 12:35 PM)Charger Wrote:  Give this stackoverflow answer a read:
https://stackoverflow.com/a/31714103

This isnt working, https://pastebin.com/raw/SkMntpXz


RE: How would i make this chat system escape chars? - Charger - Dec 30, 2017

(Dec 30, 2017 01:37 PM)free707 Wrote:  This isnt working, https://pastebin.com/raw/SkMntpXz

You didn't call the function anywhere?
And session_start has to be before $data="<b>".$_SESSION['username'].':</b> '.$_POST['chat']."<br>";
and you need to xss_clean the $_POST['chat'] and when you store it.


RE: How would i make this chat system escape chars? - mehtevas - Dec 30, 2017

(Dec 30, 2017 01:48 PM)Charger Wrote:  You didn't call the function anywhere?
And session_start has to be before $data="<b>".$_SESSION['username'].':</b> '.$_POST['chat']."<br>";
and you need to xss_clean the $_POST['chat'] and when you store it.

also you should "xss_clean" the $_SESSION['username']

otherwhys they can have xss in there names (obv)


RE: How would i make this chat system escape chars? - Prof. Farnsworth - Dec 30, 2017

Basically validate everything that has to do with the user.
Never trust the user.