提示是下面这个,另外刚开始的地方还有undefined怎么去掉呢? Warning: file_get_contents(baidu.com) [function.file-get-contents]: failed to open stream: No such file or directory in G:\wampserver\wamp\www\yz.php on line 4Notice: Undefined variable: i不通过 in G:\wampserver\wamp\www\yz.php on line 7
if(strpos(file_get_contents($_POST['url']),'特定的句子') !==false && in_array($_POST['url'],$arr)){
echo '通过';
}else{
echo "不通过";
}
<input type="text" name="url[]">
<input type="text" name="url[]">//可以以数组形式提交。php端循环就是了。
$urls=$_POST['url'];
for($i=0;$i<count($urls;$i++)){
if(strpos(file_get_contents($urls[$i]),'特定的句子') !==false && in_array($urls[$i],$arr)){
echo "$i通过<br>";
}else{
echo "$i不通过<br>";
}
}
数据库端:
//..............数据库连接省略....
$result=mysql_query("select url from table") or die(mysql_error());
while($row=mysql_fetch_assoc($result)){
$arr[]=$row['url']; // 构建url数组
}
$urls=$_POST['url'];
for($i=0;$i<count($urls;$i++)){
if(strpos(file_get_contents($urls[$i]),'特定的句子') !==false && in_array($urls[$i],$arr)){
echo "$i通过<br>";
}else{
echo "$i不通过<br>";
}
}
?>
<form action="yz.php?url=url[]" method="post">
<input type="text" name="url[]"><br />
<input type="text" name="url[]"><br />
<input type="text" name="url[]"><br />
<input type="button" />
</form>
这么写的,提示第三行错误.另外怎么把数据库的验证也放进去?是想数据库内容和特定句子内容同时验证,都通过的提示通过,有不通过的提示不通过
下面的html代码不知道是不是写错了
<input type="text" name="url[]"><br />
<input type="text" name="url[]"><br />
<input type="text" name="url[]"><br />
<input type="submit" />
</form>
Warning: file_get_contents(baidu.com) [function.file-get-contents]: failed to open stream: No such file or directory in G:\wampserver\wamp\www\yz.php on line 4Notice: Undefined variable: i不通过 in G:\wampserver\wamp\www\yz.php on line 7
}
$urls=$_POST['url'];
print_r($urls);$arr = array('http://baidu.com'); // 假设数据库地址
for($i=0;$i<count($urls);$i++){
$c = file_get_contents($urls[$i]);
if(in_array($urls[$i],$arr) && strpos($c,'baidu') !==false)
echo "{$urls[$i]}通过<br>";
else
echo "{$urls[$i]}不通过<br>";
}
?>
<form action="Noname11.php" method="post">
<input type="text" name="url[]" value="http://baidu.com"><br />
<input type="text" name="url[]" value="http://g.cn"><br />
<input type="text" name="url[]"><br />
<input type="submit" />
</form>
http://g.cn不通过Warning: file_get_contents() [function.file-get-contents]: Filename cannot be empty in G:\wampserver\wamp\www\yz2.php on line 7
不通过
Notice: Undefined index: url in G:\wampserver\wamp\www\yz2.php on line 9
http://baidu.com不通过
http://g.cn不通过Warning: file_get_contents() [function.file-get-contents]: Filename cannot be empty in G:\wampserver\wamp\www\yz2.php on line 12
不通过
<?php
$urls=$_POST['url'];
print_r($urls);
mysql_connect("localhost", "root", "") or
die("Could not connect: " . mysql_error());
mysql_select_db("dedecmsv57utf8sp1");
$result=mysql_query("select title FROM dede_archives") or die(mysql_error());
while($row=mysql_fetch_assoc($result)){
$arr[]=$row['url']; // 构建url数组
}
for($i=0;$i<count($urls);$i++){
$c = file_get_contents($urls[$i]);
if(in_array($urls[$i],$arr) && strpos($c,'baidu') !==false)
echo "{$urls[$i]}通过<br>";
else
echo "{$urls[$i]}不通过<br>";
}
?>
<form action="yz2.php" method="post">
<input type="text" name="url[]" value="http://baidu.com"><br />
<input type="text" name="url[]" value="http://g.cn"><br />
<input type="text" name="url[]"><br />
<input type="submit" />
</form>
==》
<input type="submit" name="submit" value="提交" />$c = file_get_contents($urls[$i]);前面加上: if(empry($urls[$i])) continue;最外层加一句: if(isset($_POST['submit'])){
你的php代码......................
}
上面都贴了这么多代码了,jordan102也给你说了这么多,
有点基础稍微改下就没问题了。
不要到头来只是死问,要加强自己的解决问题能力。