0
아래 코드는 사용자가 테이블 ($ 찾기)에 항목 ($ 사이트)을 추가 할 수있게합니다. 잘 작동한다. 그러나 때때로 사용자가 추가하는 값 외에도 테이블에 공백 값을 추가합니다.PHP/MySQL - 때로는 빈 항목이 테이블에 추가됩니다.
왜 그런가? bookprocess.php에 사전에
감사합니다,
존 그리고
<?
$find1 = urlencode($find);
print "<div class=\"siteadd\">
<form action='bookprocess.php?find=$find1' method='post'>
Add an item: <input name='site' type='text' size='50'>
<input type='submit' value='Submit'>
</form>
</div>";
?>
:
<?
$remove_array = array('http://www.', 'http://', 'https://', 'https://www.', 'www.');
$site = str_replace($remove_array, "", $_POST['site']);
$site = strtolower($site);
function check_porn_terms($input){
$porn_terms = array(here are a lot of swear words and porn terms); //add terms here
foreach($porn_terms as $term){
if(substr_count($input, $term) > 0) return false;
}
return true;
}
if(!check_porn_terms($_POST['site']))
{
session_write_close();
header("Location:http://www.site.com/index.php");
exit;
}
mysql_connect("mysqlv10", "username", "password") or die(mysql_error());
mysql_select_db("bookfeather") or die(mysql_error());
$_GET['find'] = $find;
$find = urldecode($find);
$find = mysql_real_escape_string($find);
$site = mysql_real_escape_string($site);
$illegal = array("/", "\"");
$site = str_replace($illegal, '', $site);
mysql_query("INSERT INTO `$find` VALUES (NULL, '$site',1,0)");
?>
난 당신이 뒤로 다음 줄을 게시 생각 "$ _GET을 [ '발견'] = $ 찾기;" –