<form action="article_validate.php" method="post" >
<ul>
<li >
<input name="keywords" class="textbox2" type="text" id="demo" value="" style=" width:171px; height:22px; border:1px solid #741918; line-height:22px; line-height:22px!important; background-color:#ffffff;color:#7a0106; letter-spacing:2px; text-align:left; " /></li>
<li style="height:28px;" >
<input type ="image" img="img" src="images1/validate_button_search.jpg" width="58" height="23" onclick="return number();" />
</li>
</ul>
</form>
<div id="print_yn">
<?
error_reporting(0);
include("ky_database/cls_mysql.php");
if($_POST['keywords'] != ""){
$sql = "select * from ky_number where number='$keywords'";
echo $keywords; $rs = mysql_query($sql);
$a = mysql_num_rows($rs);
if ($a > 0){
echo "此产品为正品";
}else{
echo "此产品非正品!";
}
}
?>
<ul>
<li >
<input name="keywords" class="textbox2" type="text" id="demo" value="" style=" width:171px; height:22px; border:1px solid #741918; line-height:22px; line-height:22px!important; background-color:#ffffff;color:#7a0106; letter-spacing:2px; text-align:left; " /></li>
<li style="height:28px;" >
<input type ="image" img="img" src="images1/validate_button_search.jpg" width="58" height="23" onclick="return number();" />
</li>
</ul>
</form>
<div id="print_yn">
<?
error_reporting(0);
include("ky_database/cls_mysql.php");
if($_POST['keywords'] != ""){
$sql = "select * from ky_number where number='$keywords'";
echo $keywords; $rs = mysql_query($sql);
$a = mysql_num_rows($rs);
if ($a > 0){
echo "此产品为正品";
}else{
echo "此产品非正品!";
}
}
?>
$key = $_POST['keywords'];
echo $key;
<ul>
<li >
<input name="keywords" class="textbox2" type="text" id="demo" value="" style=" width:171px; height:22px; border:1px solid #741918; line-height:22px; line-height:22px!important; background-color:#ffffff;color:#7a0106; letter-spacing:2px; text-align:left; " /> </li>
<li style="height:28px;" >
<input type ="image" img="img" src="images1/validate_button_search.jpg" width="58" height="23" onclick="return number();" />
</li>
</ul>
</form>
<div id="print_yn">
<?
error_reporting(0);
include("ky_database/cls_mysql.php");
$keywords = $_POST['keywords'];
if( !$keywords= ""){
$sql = "select * from ky_number where number=$keywords";
echo $keywords; $rs = mysql_query($sql);
$a = mysql_num_rows($rs);
if ($a > 0){
echo "此产品为正品";
}else{
echo "此产品非正品!";
}
}
?>
用到需要从这些数组中取
PHP 超全局变量
$GLOBALS
包含一个引用指向每个当前脚本的全局范围内有效的变量。该数组的键名为全局变量的名称。从 PHP 3 开始存在 $GLOBALS 数组。
$_SERVER
变量由 web 服务器设定或者直接与当前脚本的执行环境相关联。类似于旧数组 $HTTP_SERVER_VARS 数组(依然有效,但反对使用)。
$_GET
经由 URL 请求提交至脚本的变量。类似于旧数组 $HTTP_GET_VARS 数组(依然有效,但反对使用)。
$_POST
经由 HTTP POST 方法提交至脚本的变量。类似于旧数组 $HTTP_POST_VARS 数组(依然有效,但反对使用)。
$_COOKIE
经由 HTTP Cookies 方法提交至脚本的变量。类似于旧数组 $HTTP_COOKIE_VARS 数组(依然有效,但反对使用)。
$_FILES
经由 HTTP POST 文件上传而提交至脚本的变量。类似于旧数组 $HTTP_POST_FILES 数组(依然有效,但反对使用)。详细信息请参阅 POST 方法上传。
$_ENV
执行环境提交至脚本的变量。类似于旧数组 $HTTP_ENV_VARS 数组(依然有效,但反对使用)。
$_REQUEST
经由 GET,POST 和 COOKIE 机制提交至脚本的变量,因此该数组并不值得信任。所有包含在该数组中的变量的存在与否以及变量的顺序均按照 php.ini 中的 variables_order 配置指示来定义。此数组在 PHP 4.1.0 之前没有直接对应的版本。参见 import_request_variables()。
$sql = "select * from ky_number where number='$keywords'";
echo $keywords; $rs = mysql_query($sql);
$keywords 改为 $_POST['keywords'];或者是$_REQUEST['keywords']。皆可 <?
error_reporting(0);
include("ky_database/cls_mysql.php");
if($_POST['keywords'] != ""){
$keywords = $_POST['keywords'];
$sql = "select * from ky_number where number='".mysql_real_escape_string($keywords)."'";
echo $keywords; $rs = mysql_query($sql);
$a = mysql_num_rows($rs);
if ($a > 0){
echo "此产品为正品";
}else{
echo "此产品非正品!";
}
}
?>
$_POST['文本框的name或id']$_POST,大写。。php大小写敏感