Hi RR and WP,
I am confused, I am using 'mysql_escape_string' and it doesn't seem like it's doing anything.
Also, my form is not emailing it is adding the users post to our guestbook (really just a blog) directly.
Here is the complete code to add the users post. (minus the bad words, so I don't insult anyone ).
include "admin/x.php";
$s=$_SERVER["REMOTE_ADDR"];
$ipbancheck="SELECT * from gb_banip where IP='$s'";
$ipbancheck2=mysql_query($ipbancheck);
while($ipbancheck3=mysql_fetch_array($ipbancheck2))
{
$IPBANNED=$ipbancheck3[IP];
}
if ($IPBANNED)
{
print "You have been banned from posting";
}
else
{
if (!isset($_POST['submit']))
{
print "<table border='1' cellpadding='6' bgcolor='#e1e1e1'><tr><td>";
print "<form method='post' action='addentry.php' name='form'>";
print "<b>Name: (required)</b><br> <input type='text' name='name' size='40'><br>";
print "<b>(optional) Homepage(include http://):</b><br><input type='text' name='homepage' size='40'><br>";
print "<b>(optional) E-mail:</b><br><input type='text' name='email' size='40'><br>";
print "<b>Comment:</b><br>";
print "<textarea rows='6' name='comment' cols='45'></textarea><br>";
print "<input type='submit' name='submit' value='submit'>";
print "</form><br>";
}
else if (isset($_POST['submit']))
{
$name=$_POST['name'];
$country=$_POST['country'];
$email=$_POST['email'];
$homepage=$_POST['homepage'];
$aim=$_POST['aim'];
$icq=$_POST['icq'];
$yim=$_POST['yim'];
$msn=$_POST['msn'];
$comment=addslashes($_POST['comment']);
if(!$name || !$comment)
{
print "<font color='red'>Name or comment not entered, please go back and sign again</font><br>";
}
else
{
// Filter out the bad content
$Keyword = (isset($_POST['comment'])) ? $_POST['comment'] : '';
$trimmedKeyword = trim($Keyword);
$trimmedKeyword = stripslashes($trimmedKeyword);
//filter special characters such as % ^ &
$filter = array("truncate", "alter", "mysql_query(", "base64_encode(", "base64_decode(", "escapeshellarg(", "exec(", "passthru(", "proc_closes(", "proc_get_status(", "proc_nice", "proc_open(", "proc_terminate(", "shell_exec(", "system(", "set", "drop", "where", "insert", "select", "table1", "table2", "table3", "drop", "insert", "update", "delete", "POST", "GET", "'", "`","~", "\"" , "\\" , "!", "@" , "#" , "$" , "%" , "^" , "&" , "*" , "(", ")" , "+" , "{" , "}" , "[" , "]" , "<" , ">" , ";" , ":" , "?" , "/" ,"//" , "|" , "=", "http", "://", "www.","[url=http://x", "viagra", "x", ".com", ".org", ".edu", "buy adipex", "adipex", "phen", "x", "x", "x", "x", "web hosting", "pay day loans", "auto", "credit card terminal", "Money Makers", "x", "x", "xCo.", "x", "airline ticket", "spyware windows nt", "x", "spyware scan", "x", "microsoft sql server", "online tarot reading", "phentermine buy online", "prescription drugs", "pharmacy canada", "radiology continuing educ", "dell notebook", "valium tablet", "installing replacement", "installing replacement wi", "ibm notebook battery", "x", "flower silk", "play poker free", "sql server driver", "www", "auto insurance", "united airline fare", "sport betting online", "spyware remover", "viagra alternative", "air plane ticket", "notebook refurbished", "tramadol cheap price", "travel insurance quotes", "epson printer ink", "x", "x", "x", "x", "x", "x", "x", "x", "x", "online cigarettes", "home equity loan", "x", "bad credit", "free casino cash", "air ticket", "[url]", "[/url]", "[url", "[url=", "buy phentermine", "Buy phentermine", "Buy Phentermine", "gbook", "x", "x");
$trimmedKeyword = str_replace($filter, '', $trimmedKeyword);
$trimmedKeyword = preg_replace('#\s+#',' ',$trimmedKeyword);
$trimmed_arrayKeyword = explode(" ",$trimmedKeyword);
$trimmed = mysql_escape_string($trimmedKeyword);
//////////////////
// Insert the data now its cleaned
$r=$_SERVER["REMOTE_ADDR"];
$day=date("D M d, Y H:i:s");
$timegone=date("U") ; //seconds since Jan 1st, 1970
$putinguestbook="INSERT INTO gbook(name, country, mail, homepage, comment, realtime, aim, icq, yim, msn, time,IP) VALUES('$name','$country','$email','$homepage','$trimmed','$day','$aim','$icq','$yim','$msn','$timegone','$r')";
mysql_query($putinguestbook);
print "Thanks for posting, you will now be redirected <META HTTP-EQUIV = 'Refresh' Content = '2; URL =index.php'> ";
}
}
}
As you can see, I mysql_escape_strig the $trimmedwords then set that to $trimmed and insert into the db. Did I somehow, nullify that command in my code???
Thanks,
Don