我正在尝试提交此表单,在提交后,它应该重定向到自己。但是,我面临的问题是,在我提交表单后,它会显示以下错误:
Notice: Undefined index: id in C:\xampp\htdocs\iNetLink\configuration.php on line 9
这是我的表单文件:
<?php include("header.php");
if(ISSET($_POST['node'])){
$nodeID = $_POST['node'];
}else{
$nodeID = 0;
}
$requestID = $_GET['id'];
$qConfigurationForm = "SELECT * FROM configuration WHERE request_id = '$requestID' ";
$rConfigurationForm = $connection->query($qConfigurationForm);
$rowCount = $rConfigurationForm->rowCount();
$row = $rConfigurationForm->fetch();
if($rowCount > 0){
?>
<section id="content">
<section class="vbox">
<section class="scrollable padder">
<ul class="breadcrumb no-border no-radius b-b b-light pull-in">
<li><a href="index.html"></a></li>
</ul>
<div class="m-b-md">
<h3 class="m-b-none">Configuration</h3>
</div>
<section class="panel panel-default">
<!-- Tabs for navigation -->
<?php include("tabs.php");?>
</section>
<!-- Tabs for navigation ended -->
<!--forms-->
<section class="panel panel-default">
<header class="panel-heading font-bold">Line Configuration Information</header>
<div class="panel-body">
<form class="form-horizontal" method="post" action="configuration.php" data-validate="parsley">
<div class="col-md-6">
<div class="form-group">
<label class="col-sm-3 control-label" for="requestID"></label>
<div class="col-sm-6">
<input type="hidden" name="requestID" id="requestID" value="<?php echo $requestID;?>">
<input type="hidden" name="isUpdate" value="1" />
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Node</label>
<div class="col-sm-6">
<select name="node" id="node" class="form-control m-b" onchange="GetId()" data-required="true">
<option></option>
<?php
$qNode = "SELECT id,node FROM node WHERE id = '$nodeID'";
$rNode = $connection->query($qNode);
foreach($rNode as $node){
$nodeid = $node['id'];
$nodeName = $node['node'];
echo "<option value=\"$nodeid\" selected=\"selected\">$nodeName</option>";
}
echo "<optgroup></optgroup>";
$qNode = "SELECT id,node FROM node WHERE `status` = 1";
$rNode = $connection->query($qNode);
foreach($rNode as $node){
$nodeid = $node['id'];
$nodeName = $node['node'];
echo "<option value=\"$nodeid\">$nodeName</option>";
}
?>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Connection Type</label>
<div class="col-sm-6">
<select name="connectionType" id="connectionType" class="form-control m-b" data-required="true">
<option></option>
<?php
$connection_type = $row['connection_type'];
$qConnectionConfigType = "SELECT * FROM `connection_type_config` WHERE id = '$connection_type'";
$rConnectionConfigType = $connection->query($qConnectionConfigType);
foreach($rConnectionConfigType as $connectionConfigType){
$connectionConfigID = $connectionConfigType['id'];
$connectionType = $connectionConfigType['connection_type'];
echo "<option value=\"$connectionConfigID\" selected=\"selected\">$connectionType</option>";
}
echo "<optgroup></optgroup>";
$qConnectionConfigType = "SELECT * FROM `connection_type_config`";
$rConnectionConfigType = $connection->query($qConnectionConfigType);
foreach($rConnectionConfigType as $connectionConfigType){
$connectionConfigID = $connectionConfigType['id'];
$connectionType = $connectionConfigType['connection_type'];
echo "<option value=\"$connectionConfigID\">$connectionType</option>";
}
?>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="timeSlot">Time Slot</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="timeSlot" name="timeSlot" value="<?php echo $row['time_slot'];?>" data-required="true">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="dslUnifiNo">DSL/Unifi Username</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="dslUnifiNo" name="dslUnifiNo" value="<?php echo $row['dsl_username'];?>">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="remarksConfig">Remarks</label>
<div class="col-sm-6">
<textarea rows="4" cols="50" class="form-control" id="remarksConfig" name="remarksConfig"><?php echo $row['remarks'];?></textarea>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="col-sm-3 control-label">Port</label>
<div class="col-sm-6">
<select name="portNo" id="portNo" name="portNo" class="form-control m-b" data-required="true">
<!-- <option></option>
<?php
$qPortNo = "SELECT * FROM node_port WHERE node_id = '$nodeID' AND `status` = 1";
$rPortNo = $connection->query($qPortNo);
foreach($rPortNo as $portNo){
$portID = $portNo['id'];
$number = $portNo['port_no'];
echo "<option value=\"$portID\">$number</option>";
}
?> -->
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">E1 Circuit No.</label>
<div class="col-sm-6">
<select name="e1circuitNo" id="e1circuitNo" class="form-control m-b">
<option></option>
<?php
$e1_circuit_no = $row['e1_curcuit_no'];
$qE1Type = "SELECT * FROM `e1_type` WHERE id = '$e1_circuit_no'";
$rE1Type = $connection->query($qE1Type);
foreach($rE1Type as $e1Type){
$e1ID = $e1Type['id'];
$type = $e1Type['type'];
echo "<option value=\"$e1ID\" selected=\"selected\">$type</option>";
}
echo "<optgroup></optgroup>";
$qE1Type = "SELECT * FROM `e1_type`";
$rE1Type = $connection->query($qE1Type);
foreach($rE1Type as $e1Type){
$e1ID = $e1Type['id'];
$type = $e1Type['type'];
echo "<option value=\"$e1ID\">$type</option>";
}
?>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Changed Date</label>
<div class="col-sm-6">
<input class="input-m input-m form-control" type="date"
data-date-format="dd-mm-yyyy" id="changedDate" name="changedDate" value="<?php echo $row['changed_date'];?>" data-required="true">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="dslUnifiIp">DSL/Unifi IP</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="dslUnifiIp" name="dslUnifiIp" value="<?php echo $row['dsl_ip'];?>">
</div>
</div>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<div class="btn-toolbar pull-right">
<input type="hidden" name="id" value="<?=$requestID;?>">
<input class="btn btn-warning " type="reset" value="Reset" name="reset" >
<input class="btn btn-info " type="submit" value="Save Draft" name="saveDraft">
<input class="btn btn-success " type="submit" value="Submit" name="Submit">
</div>
</div>
</form>
</div>
</section>
第9行是$requestID = $_GET['id'];
以下是表单的执行者:
<?php
include("dbconnection.php");
session_start();
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
$requesterID = $_SESSION['id'];
print_r($_POST);
$node = $_POST['node'];
$connectionType = $_POST['connectionType'];
$timeSlot = $_POST['timeSlot'];
$dslUnifiNo = $_POST['dslUnifiNo'];
$remarksConfig = $_POST['remarksConfig'];
$port = $_POST['port'];
$e1circuitNo = $_POST['e1circuitNo'];
$changedDate = $_POST['changedDate'];
$dslUnifiIp = $_POST['dslUnifiIp'];
$requestID = $_POST['requestID'];
if(ISSET($_POST['isUpdate'])){
$qinsert = "UPDATE configuration SET
node = '$node',
connection_type = '$connectionType',
time_slot = '$timeSlot',
dsl_username = '$dslUnifiNo',
remarks = '$remarksConfig',
port = '$port',
e1_curcuit_no = '$e1circuitNo',
changed_date = '$changedDate',
dsl_ip = '$dslUnifiIp'
WHERE request_id = '$requestID'";
}else
{
$qinsert = "REPLACE INTO configuration SET
node = '$node',
connection_type = '$connectionType',
time_slot = '$timeSlot',
dsl_username = '$dslUnifiNo',
remarks = '$remarksConfig',
port = '$port',
e1_curcuit_no = '$e1circuitNo',
changed_date = '$changedDate',
dsl_ip = '$dslUnifiIp',
request_id = '$requestID'";
$requestID = $connection->lastInsertId();
if($status == 1){
$action = "lineApplication.php";
$dateCreated = date("Y-m-d H:i:s");
$userTypeID = 5;
$qinsertTss = "INSERT INTO notifications SET
user_id = '$requesterID',
action = '$action',
item_id = '$requestID',
created_at = '$dateCreated',
receive_user_type_id = '$userTypeID'";
$rinsertTss = $connection->query($qinsertTss);
}
}
$rinsert = $connection->query($qinsert);
header("location:configuration.php?id=$requestID");
帮助! :)
答案 0 :(得分:0)
你发送给配置文件的POST是不是你的执行者?
<form class="form-horizontal" method="post" action="configuration.php" data-validate="parsley">
也...
$requestID = $_GET['id'];
这会出错,因为在POST期间$ _GET ['id']不可用。修复你的代码试试这个:
$requestID = (isset($_GET['id'])) ? $_GET['id'] : 'add ID for POST';
或确保您的表单正在发送正确的PHP文件