<form method='get' action='y.php'>
<div>
<input type='text' id='txtName' name='txtName'/>
<input type='submit' value='submit' id='submit'/>
</div>
</form>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'GET')
{
if (isset($_GET['btnSave'])) {
$name=isset(($_GET['txtName'])?isset($_GET['txtName']:'');
//then Logic of insert goes here
}
}
?>
因此在移动到y.php
之前必须保存记录。 但我不能得到$name
价值,作为给予y.php
的行动。 我怎样才能得到$name
其中包含文本框中的值。以PHP提交GET页面时保存信息
如果您更改此(相同/当前)页面记录的操作将进入数据库,而没有任何缺陷或错误。
那么为什么不使用'POST'?另外,为什么使用'ternary operator'检查变量'isset',然后再次在它周围分配值wrap'isset'? – Script47
由于@ script47说isset - 它应该是'$ name = isset($ _GET ['txtName'])? $ _GET ['txtName']:'';' – RamRaider