日期:2014-05-17  浏览次数:20507 次

php提交给form怎么就取不到值?请教
<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 "此产品非正品!";
}
}
?>

------解决方案--------------------
$keywords 改为 $_POST['keywords'];
------解决方案--------------------
PHP code

$key = $_POST['keywords'];
echo $key;

------解决方案--------------------
number='$keywords' 中的$keywords没有赋值

$key = $_POST['keywords'];

------解决方案--------------------
<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");
$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 "此产品非正品!";
}
}
?>
------解决方案--------------------
4楼正解
------解决方案--------------------
在最近的php版本中,全局变量都放在了几个全局数组中了
用到需要从这些数组中取
PHP 超全局变量 
$GLOBALS 
包含一个引用指向每个当前脚本的全局范围内有效的变量。该数组的键名为全局变量的名称。从 PHP 3 开始存在 $GLOBALS 数组。