ZulfadlyAshBurn Posted July 11, 2011 Share Posted July 11, 2011 I have just finished coding the front end of my social integration site for my CCA. I'm having a slight problem in preventing users from posting cross-side scripting or type scripts in the text box. How can I disallow users/disable users from typing <scripts> in the text area and send to server. this is my script. <form> <textarea id="textfm" name="text"; onclick="this.innerHTML = '';" onKeyPress="return submitenter(event)">Say something...</textarea> <input type="button" value="Share!" onClick="ajaxSubmit();"/> the ajax all works this is where it saves the code $text = "<img src='images/say.png' height='20px'/><a href='#'>Anonymous</a> " . $text . "<p style='float:right; color:#C0C0C0' align='right'><img ALIGN=ABSMIDDLE src='images/clock.png' height='20px'> " . date("d/m/y : H:i:s", time()) . "</img></p><hr color='#F0F0F0' width='100%' size='1'/>"; $rip = $_SERVER['REMOTE_ADDR']; $fp = fopen('log.txt', 'a+'); fwrite($fp, $text); fclose($fp); $fp = fopen('ip.txt', 'a+'); fwrite($fp, $rip); fclose($fp); readfile('log.txt'); } Link to comment https://forums.phpfreaks.com/topic/241712-help/ Share on other sites More sharing options...
premiso Posted July 11, 2011 Share Posted July 11, 2011 htmlentities strip_tags preg_replace are all viable solutions to your problem. And next time, choose a better, more descriptive subject title. Help is just so fuckin annoying. Link to comment https://forums.phpfreaks.com/topic/241712-help/#findComment-1241412 Share on other sites More sharing options...
ZulfadlyAshBurn Posted July 11, 2011 Author Share Posted July 11, 2011 thanks dude. i will try it out. haha. alright. helps kinda sucks now. Link to comment https://forums.phpfreaks.com/topic/241712-help/#findComment-1241415 Share on other sites More sharing options...
Kustom_Vegas Posted July 11, 2011 Share Posted July 11, 2011 this is assuming that you are passing your form and validating your forma data with PHP and not JS, which I assume that you are Link to comment https://forums.phpfreaks.com/topic/241712-help/#findComment-1241416 Share on other sites More sharing options...
ZulfadlyAshBurn Posted July 11, 2011 Author Share Posted July 11, 2011 yes, i am using ajax to pass the form to a php script which validates the form and pass back the output to the page. Link to comment https://forums.phpfreaks.com/topic/241712-help/#findComment-1241418 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.