[英]Why doesn't this $_GET work
I am just trying to get the values from a table, but for some reason GET isn't working for me, or I am doing something wrong. 我只是想从表中获取值,但是由于某种原因,GET无法为我工作,或者我做错了什么。 Here is how I create my table in one php file:
这是我在一个php文件中创建表格的方法:
<?php
.
.
.
.
echo "<tr>";
echo "<td>Login ID</td>";
$j=1;
echo "<td><input name=$j type='text' value='$line[$j]' size=20/></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Name</td>";
$j=2;
echo "<td><input name=$j type='text' value='$line[$j]' size=20/></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Password</td>";
$j=3;
echo "<td><input name=$j type='text' value='$line[$j]' size=20/></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Birthday</td>";
$j=4;
echo "<td><input name=$j type='text' value='$line[$j]' size=20/></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Address</td>";
$j=5;
echo "<td><input name=$j type='text' value='$line[$j]' size=20/></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Email</td>";
$j=6;
echo "<td><input name=$j type='text' value='$line[$j]' size=20/></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Phone Number</td>";
$j=7;
echo "<td><input name=$j type='text' value='$line[$j]' size=20/></td>";
echo "</tr>";
?>
The names should be the number 1-7 right? 名称应该是数字1-7,对不对?
In another php file I attempt to access the values in those fields with he following code: 在另一个php文件中,我尝试使用以下代码访问这些字段中的值:
<?php
.
.
.
.
$login_id = $_GET['1'];
$name = $_GET['2'];
$pw = $_GET['3'];
$bday = $_GET['4'];
$address = $_GET['5'];
$email = $_GET['6'];
$phno = $_GET['7'];
echo "new: $login_id, $name, $pw, $bday, $address, $email, $phno";
?>
Here is what I end up getting back: new: , , , , , ,
这就是我最终得到的东西:
new: , , , , , ,
,,,,,,
So what is it that I am doing wrong? 那我做错了什么呢? I can't seem to find anything wrong with my code.
我的代码似乎找不到任何错误。 I know I should probably be using $_POST for the password.
我知道我应该使用$ _POST作为密码。
<?php
echo "<form action='otherfile.php' method='get'><tr>";
echo "<td>Login ID</td>";
$j=1;
echo "<td><input name=$j type='text' value='$j' size=20/></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Name</td>";
$j=2;
echo "<td><input name=$j type='text' value='$j' size=20/></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Password</td>";
$j=3;
echo "<td><input name=$j type='text' value='$j' size=20/></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Birthday</td>";
$j=4;
echo "<td><input name=$j type='text' value='$j' size=20/></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Address</td>";
$j=5;
echo "<td><input name=$j type='text' value='$j' size=20/></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Email</td>";
$j=6;
echo "<td><input name=$j type='text' value='$j' size=20/></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Phone Number</td>";
$j=7;
echo "<td><input name=$j type='text' value='$j' size=20/></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Submit Data</td>";
echo "<td><input name='submitdata' type='submit' value='submit' size=20/></td>";
echo "</tr><form>";
?>
if you want submit then get the all value in otherfile.php file 如果要提交,则在otherfile.php文件中获取所有值
try its working... 尝试工作...
You have not put the <form>
tag. 您尚未放入
<form>
标记。 Add tag in begining 开始添加标签
<form action='another_page.php' method='get'>
and in the end write 最后写
<input type='submit' name='submit>
</form>
What it will do on submit it will forward the values to the another page. 提交时将执行的操作会将值转发到另一页。
<form name="login" method="get" action="youraction.php">
echo "<td><input name=$j type='text' value=$j /></td>";
</form>
youraction.php
---------------
<?php
if($_GET)
{
print_r($_GET);
}
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.