PHP fopen并传递变量以获取变量值

时间:2013-02-09 13:42:48

标签: php variables fopen

我正在尝试为我的简单CMS脚本创建一个许可证系统,我正在使用fopen函数来执行此操作,但是我收到了错误。 这是我的html表单的代码:

<form action="check.php" method="post">
<div><label id="Label1" for="domain">Domain : </label><input name="domain" type="text" /></div>
<div><label id="Label2" for="lis">Liscence : </label><input name="liscode" type="text" /></div>
<div><input name="Submit1" type="submit" value="submit" /></div>
</form>

表格行动:

<?php
$dom = $_POST['domain'];
$lis = $_POST['liscode'];
$URL = "http://localhost/check/checklic.php?dom=".$dom."&lis=".$lis."";
$handle = fopen($URL, "r");
if ($accept = 0){
$letter = "Invalid License Key";
}
else
{
$letter = " Congratulation You Have Been License";
}
echo $letter;
?>

和我的文件要使用我的数据库检查许可证是:

<?php
$domain = $_GET['dom'];
$liskey = $_GET['lis'];
$host = "localhost";
$user = "root";
$pass = "admin";
$db = "test";
$dblink = new PDO("mysql:host=$host;dbname=$db",$user,$pass);
$mysql_liscode = "SELECT liscode FROM lis WHERE domain = '".$domain."'";
$query_liscode = $dblink->query($mysql_liscode) or die("failed!");
$liscode = $query_liscode->fetch(PDO::FETCH_ASSOC);
$count = $query_liscode->rowCount();
if ($count = 0){
$accept = 0;
}
elseif ($liscode['liscode'] != $liskey){
$accept = 0;
}
else{
$accept = 1;
}
?>

请注意,许可证检查器位于

http://localhost/check

表格及其行动在

http://localhost/site

消息始终

Warning: fopen(http://localhost/check/checklic.php?dom=ammar.com&lis=1234) [function.fopen]:
failed to open stream: No error in C:\AppServ\www\site\check.php on line 5
Congratulation You Have Been Liscienced

即使我在表单中插入了错误的许可信息

请帮助。

2 个答案:

答案 0 :(得分:0)

if ($accept = 0){更改为if ($accept == 0){,将$count更改为

答案 1 :(得分:0)

我将在这里走出一条巨大的障碍,并建议问题是网址,

试试吧

$URL = "http://localhost/check/checklic.php?dom=".$dom."&lis=".$lis;
$handle = @fopen($URL, "r");