I have two PHP pages that interact. The first one I select data and present it to th epage for editing. Each row has a submit that references an update page. Every submit works to update the DB EXCEPT for the first row. I set the update page to print the post data and to refresh for 1 second so I could see the post data. Editing the first row does not produce any post data in the second page. So I must have an error in the 1st page?
Here is the 1st page:
[code=html]<!DOCTYPE html>
<html>
<head>
<Title>Edit Template Settings</title>
</head>
<body>
<p>CQ Simple Phone Provisioning System</p>
<hr>
<form action=”” method=”post”>
Template name to edit: <input type=”text” name=”tname”><br><input type=”submit”>
<?php
$tempname = $_POST[‘tname’];
echo $tempname;
$con = mysqli_connect(‘localhost’,’root’,”);
$sql = “Select * from cqadmin.keys where templatename = ‘$tempname'”;
$records = mysqli_query($con,$sql);
?>
<table>
<tr>
<th></th>
<th></th>
<th>Key Name</th>
<th>Key Type</th>
<th>Value</th>
<th>Label</th>
</tr>
<?php
while($row = mysqli_fetch_array($records))
{
echo “<tr><form action=update.php method=post>”;
echo”<td><input type=hidden name=id value='”.$row[‘id’].”‘></td>”;
echo”<td><input type=hidden name=name value='”.$row[‘templatename’].”‘></td>”;
echo”<td><input type=hidden name=keyid value='”.$row[‘keyid’].”‘></td>”;
echo”<td><input type=text name=key value='”.$row[‘keyname’].”‘><Readonly></td>”;
echo”<td><input type=text name=type value='”.$row[‘keytype’].”‘></td>”;
echo”<td><input type=text name=value value='”.$row[‘keyvalue’].”‘></td>”;
echo”<td><input type=text name=label value='”.$row[‘keylabel’].”‘></td>”;
echo “<td><input type=submit>”;
echo”</form></tr>”;
}
?>
</body>
</html>
And the UPdate page
[code=html]<?php
//Connect to MYSQL
$conn = mysqli_connect(“localhost”,”root”,””);
if ($conn->connect_error) {
die(“Connection failed: ” . $conn->connect_error);
}
print_r($_POST);
$sql = “UPDATE cqadmin.keys SET templatename=’$_POST[name]’,keyname=’$_POST[key]’,keyid=’$_POST[keyid]’,keytype=’$_POST[type]’,keyvalue=’$_POST[value]’,keylabel=’$_POST[label]’ where id=’$_POST[id]'”;
//Execute the query
if ($conn->query($sql) === TRUE) {
header(“refresh:10; url=keys.php”);
} else {
echo “Error: ” . $sql . “<br>” . $conn->error;
}
$conn->close();
?>
Can someone tell me what is going on? I have tried different browsers. There are no errors
Thanks