我在提交表单时没有获取输入值时遇到问题。
使用此代码可以概览domein记录,其中ID将显示将要编辑的ID。
我必须在$ _SESSION wen按下编辑中获取值。
<?php
require_once("classes/Login.php");
require_once("classes/versio.class.php");
require_once("config/config.php");
require_once("includes/includes.php");
require_once("includes/bootstrap.php");
require_once("includes/header.php");
if($login->isUserLoggedIn() != true) {
header("Location: ./login.php");
}
$domain = $_GET['domain'];
$tld = $_GET['tld'];
unset($command);
$command = array(
"command" => "DomainsDNSListRecords",
"domain" => $domain,
"tld" => $tld
);
$api = new Versio_api();
$versio = $api->api_send($command);
if($versio['success']==0) {
echo("Fout opgetreden. Fout code: ".$versio['command_response_code'].". Fout text: ".$versio['command_response_message']."");
}
else {
if($versio['total_count']>0)
{
require_once("includes/submenu.php");
if(isset($_POST['submit'])) {
$_SESSION["name"] = $_POST['rName'];
$_SESSION["type"] = $_POST['rType'];
$_SESSION["value"] = $_POST['rVal'];
$_SESSION["prio"] = $_POST['rPrio'];
$_SESSION["ttl"] = $_POST['rTtl'];
}
?>
<div class="col-sm-9 col-md-9">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Klantenpaneel</h3>
</div>
<div class="panel-body">
<form method="post" action="">
<table class="table table-striped">
<thead>
<tr>
<th>Naam</th>
<th></th>
<th>Type</th>
<th></th>
<th>Waarde</th>
<th></th>
<th>Prioriteit</th>
<th></th>
<th>TTL</th>
<th></th>
</tr>
</thead>
<table class="table table-striped table-bordered">
<tbody>
<?php
$teller = 1;
while($versio['total_count']>=$teller) {
?>
<tr>
<td><input class="table-input" type="text" name="rName" value="<?php echo $versio['name_'.$teller]; ?>"></td>
<td><select class="table-input" name="rType">
<option value="<?php echo $versio['type_'.$teller]; ?>"><?php echo $versio['type_'.$teller]; ?></option>
<option value="A">A</option>
<option value="MX">MX</option>
<option value="CNAME">CNAME</option>
<option value="SRV">SRV</option>
<option value="TXT">TXT</option>
<option value="SPF">SPF</option>
</select></td>
<td><input class="table-input" type="text" name="rVal" value="<?php echo $versio['value_'.$teller]; ?>"></td>
<td><input class="table-input" type="text" name="rPrio" value="<?php echo $versio['prio_'.$teller]; ?>"></td>
<td><select class="table-input" type="text" name="rTtl">
<?php
$_SESSION["ttl"] = $versio['ttl_'.$teller];
$getal = $_SESSION["ttl"];
$_60 = 60;
$uitkomst = $getal / $_60 / $_60;
echo $uitkomst;
?>
<option value="<?php echo $versio['ttl_'.$teller]; ?>"><?php echo $uitkomst ?> uur</option>
<option value="300">5 min</option>
<option value="3600">1 uur</option>
<option value="7200">2 uur</option>
<option value="14400">4 uur</option>
<option value="28800">8 uur</option>
<option value="86400">24 uur</option>
</select>
</td>
<td style="width: 10px;"><a href="edit.record.php?id=<?php echo $versio['id_'.$teller]; ?>&tld=<?php echo $tld ?>&domain=<?php echo $domain ?>" style="color:blue; text-decoration:none;"
onclick="return confirm('Are you sure you want to Edit this item?');">
<p class="glyphicon glyphicon-pencil text-primary" type="submit" name="submit"></p></a></td>
<td style="width: 10px;"><a href="remove.record.php?id=<?php echo $versio['id_'.$teller]; ?>&tld=<?php echo $tld ?>&domain=<?php echo $domain ?>" style="color:red; text-decoration:none;"
onclick="return confirm('Are you sure you want to delete this item?');">
✘</a></td>
</tr>
<?php $teller++;
}
?>
</tbody>
</table>
<a href="add.record.php?domain=<?php echo $domain ?>&tld=<?php echo $tld ?>">
Record toevoegen</a>
</form>
</div>
</div>
<?php
} else {
echo("Er zijn geen DNS records gevonden voor dit domein.");
}
}
?>
<?php require_once("includes/footer.php"); ?>
<?php
require_once("classes/versio.class.php");
$domain = $_GET['domain'];
$tld = $_GET['tld'];
$id = $_GET['id'];
unset($command);
$command = array(
"command" => "DomainsDNSDeleteRecord",
"domain" => $domain,
"tld" => $tld,
"id" => $id
);
$api = new Versio_api();
$versio = $api->api_send( $command );
if($versio['success']==0) {
echo("Fout opgetreden. Fout code: ".$versio['command_response_code'].". Fout text: ".$versio['command_response_message']."");
} else {
unset($command);
$command = array(
"command" => "DomainsDNSAddRecord",
"domain" => $domain,
"tld" => $tld,
"name" => $_SESSION['name'],
"type" => $_SESSION['type'],
"value" => $_SESSION['value'],
"prio" => $_SESSION['prio'],
"ttl" => $_SESSION['ttl']
);
$api = new Versio_api();
$versio = $api->api_send($command);
if($versio['success']==0) {
echo("Fout opgetreden. Fout code: ".$versio['command_response_code'].". Fout text: ".$versio['command_response_message']."");
}else{
header ("location: records.php?domain=$domain&tld=$tld");
}
}
?>