" <script>alert("XSS")</script> "
when i read the message a message box pops up.
I have had a look at the code and there are way the coder has tried to stop sql injection.
Is there any way to stop script tags ? or tags all together ?
Here is the pm script
<?php
$user = $_SESSION['username'];
$message = $_POST['forward2'];
if (isset($_POST['submit']))
{
if ( !isset ( $_POST['message'] ) ) { return false; }; // Has user sent a username?
$message = preg_match("/([A-Za-z0-9-_\ ])/", $_POST['message']); // Is it a valid string?
if ( !$message )
{
die("Prevented SQL Injection.");
}
$message = strip_tags( addSlashes( $_POST['message'] ) ); // Remove any nasties
// if the form has been submitted, this inserts it into the Database
;
$to_user = mysql_real_escape_string($_POST['to_user']);
$from_user = mysql_real_escape_string($_SESSION['username']);
$message = mysql_real_escape_string($_POST['message']);
mysql_query("INSERT INTO messages (to_user, message, from_user) VALUES ('$to_user', '$message', '$from_user')")or die(mysql_error());
echo "PM succesfully sent!";
}
else
{
// if the form has not been submitted, this will show the form
?>
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
<table border="0" width="388">
<tr>
<td colspan="2"><h3>Personal Messaging System</h3></td>
</tr>
<tr>
<td>To User: </td>
<td><input maxlength="32" name="to_user" type="text" value="" />
</td>
</tr>
<tr>
<td>Message: </td>
<td><textarea cols="30" name="message" rows="5"></textarea>
</td>
</tr>
<tr>
<td align="center" colspan="2"><div align="left">
<input name="submit" type="submit" value="Send Message" />
</div></td>
</tr>
</table>
</form>
<?php
}
?>
This post has been edited by rpgmaker: 28 January 2012 - 01:49 PM

New Topic/Question
Reply



MultiQuote







|