2

我有以下表格:

<form id="frmAeroportonew" name="frmAeroportonew" method="post" action="<?php echo $editFormAction; ?>">
<table>      
  <tr>
    <td><input name="iata" type="text" id="iata" value="" /></td>
    <td><input name="icao" type="text" id="icao" value="" /></td>
    <td><input name="cidade" type="text" id="cidade" value="" /></td>
    <td><input name="pais" type="text" id="pais" value="" /></td>
    <td><input name="destino" type="checkbox" id="destino" value="" /></td>
    <td><input name="alternativo" type="checkbox" id="alternativo" value="" /></td>
    <td><input name="h24" type="checkbox" id="h24" value="" /></td>
    <td><input name="btnaeroportonew" id="btnaeroportonew" type="submit" value="+" /></td>
  </tr>
</table>
<input type="hidden" name="MM_insert" value="frmAeroportonew">

想法是提交此表单,而不是重定向到另一个页面 (teste_redirect.php),将输入 (id=iata) 值附加到 url (teste_redirect.php?iata=input_value)。

PHP 代码是在 dreamweaver cs6 中制作的:

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "frmAeroportonew")) {
  $insertSQL = sprintf("INSERT INTO tblaeroportos (iata, icao, cidade, pais, destino, alternativo, H24) VALUES (%s, %s, %s, %s, %s, %s, %s)",
                   GetSQLValueString($_POST['iata'], "text"),
                   GetSQLValueString($_POST['icao'], "text"),
                   GetSQLValueString($_POST['cidade'], "text"),
                   GetSQLValueString($_POST['pais'], "text"),
                   GetSQLValueString(isset($_POST['destino']) ? "true" : "", "defined","1","0"),
                   GetSQLValueString(isset($_POST['alternativo']) ? "true" : "", "defined","1","0"),
                   GetSQLValueString(isset($_POST['h24']) ? "true" : "", "defined","1","0"));

  mysql_select_db($database_connect, $connect);
  $Result1 = mysql_query($insertSQL, $connect) or die(mysql_error());

  $insertGoTo = "teste_redirect.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}

我感谢您的所有帮助。谢谢

4

1 回答 1

3

将您的 insertGoto 更改为

$insertGoTo = "teste_redirect.php?iata=".$_POST['iata'];
于 2013-03-29T12:25:17.147 回答