0

我阅读了与 $_GET 和 $_POST 相关的所有问题。我没有找到适合我的情况的解决方案。代码非常简单,它应该可以工作,但是使用 $_GET 时我得到了空字段。这是我的代码:

DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Colors</title>
</head>
<body>
<h2> Project</h2>
<form method="get" action="display.php">
R:<input type="text" name="r" size="3"/> <p/>
G:<input type="text" name="g" size="3"/><p/>
B:<input type="text" name="b" size="3"/><p/>
<input type="submit" value ="Show me">
</form>
</body>
</html>

和php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Colors</title>
</head>
<body>
<h2>Color Sampler </h2>
<?php
$r=$_GET['r'];
$g=$_GET['g'];
$b=$_GET['b'];
$rgb=$r . ',' . $g . ',' . $b;
?>
R:<?php echo $r; ?>
G:<?php echo $g; ?>
B:<?php echo $b; ?>
 <p/>
<div style ="width:150px;height:150px;
background-color:rgb(<?php echo $rgb;?>"/> 
</body>
</html>

这就是我得到的:

Project 2 Color Sampler 
R: G: B: 

所以它是空的,就像它看不到他需要返回的值一样。

怎么了?

4

1 回答 1

-3

您可以删除 'method="get"',因为它默认使用。另外,尝试从 $_REQUEST 获取参数。祝你好运!

于 2013-06-23T20:27:04.407 回答