I've been tasked to fix a problem on our website and I'm not very well versed in SQL/PHP but we have a system that uses a front page datatable, displaying records from our database. When you click a serial number link in that table, it brings up a web based form/tables filled by the data from the specified record. I've now been told to make two of the tables editable so that it still shows the current fields from the database, but this way we would have the option to change them, hit the submit button and save the new values to the database.
The code below covers the instance from the front page and the query that selects the right row from our 'staging' database table and displays the info from only that record. This works fine and since I upded the code with input tags I can now edit the fields, but I've yet to implement the option to save them.
If I understand right, I would create a 'Submit' button on this page (although I was thinking of an option that may have a save button for every html table) and when the button is pressed, I would attach a SQL UPDATE statement.
I have two questions here:
If I were to edit every one of the input fields in the below code, what is the proper way to run that UPDATE statement to properly set each of those values?
If you see below, I have a formula that averages some values and I put that result in $testFinalForm. This is all done on the web page and that value doesn't exist in the database table. If I were to add testFinalForm to my database table, I would like to save that value as well.
Again, this is not something I usually have to do and I'm a bit overwhelmed so I'm just hoping for some helpful guidance.
if(isset($_GET['id']))
{
$query1 = "SELECT * FROM staging WHERE serialNumber = ".$_REQUEST['id'].";";
$result1 = mysqli_query($connect,$query1);
while($row = mysqli_fetch_array($result1)){
?>
<form>
<!--Meter Test (1) Table-->
<div class="FirstMeterTable" style=" width:100%; clear: both;">
<table style="width:100%; border:none;
border-collapse:collapse;">
<tr style="border:none;">
<th style="border:none; text-align: left;" >Meter Test</th>
<th style="border:none;">Test 1</th>
<th style="border:none;">Test 2</th>
<th style="border:none;">Test 3</th>
<th style="border:none;">Test 4</th>
<th style="border:none;">Test 5</th>
<th style="border:none;">Test 6</th>
<th style="border:none;">Test 7</th>
<th style="border:none;">Test 8</th>
</tr>
<tr style="border: none;" >
<td style="border:none; text-align: left;">Test Rate GPM: </td>
<td><input type="text" value="<? echo $row['test1TestRateGPM'];?>"> </td>
<td><input type="text" value="<? echo $row['test2TestRateGPM'];?>"> </td>
<td><input type="text" value="<? echo $row['test3TestRateGPM'];?>"> </td>
<td><input type="text" value="<? echo $row['test4TestRateGPM'];?>"> </td>
<td><input type="text" value="<? echo $row['test5TestRateGPM'];?>"> </td>
<td><input type="text" value="<? echo $row['test6TestRateGPM'];?>"> </td>
<td><input type="text" value="<? echo $row['test7TestRateGPM'];?>"> </td>
<td><input type="text" value="<? echo $row['test8TestRateGPM'];?>"> </td>
</tr>
<tr>
<td style="border:none; text-align: left;">Meter Volume: </td>
<td><input type="text" value="<? echo $row['test1MeterVol'];?>"> </td>
<td><input type="text" value="<? echo $row['test2MeterVol'];?>"> </td>
<td><input type="text" value="<? echo $row['test3MeterVol'];?>"> </td>
<td><input type="text" value="<? echo $row['test4MeterVol'];?>"> </td>
<td><input type="text" value="<? echo $row['test5MeterVol'];?>"> </td>
<td><input type="text" value="<? echo $row['test6MeterVol'];?>"> </td>
<td><input type="text" value="<? echo $row['test7MeterVol'];?>"> </td>
<td><input type="text" value="<? echo $row['test8MeterVol'];?>"> </td>
</tr>
<tr>
<td style="border:none; text-align: left;">Tester Volume: </td>
<td><input type="text" value="<? echo $row['test1TesterVol'];?>"> </td>
<td><input type="text" value="<? echo $row['test2TesterVol'];?>"> </td>
<td><input type="text" value="<? echo $row['test3TesterVol'];?>"> </td>
<td><input type="text" value="<? echo $row['test4TesterVol'];?>"> </td>
<td><input type="text" value="<? echo $row['test5TesterVol'];?>"> </td>
<td><input type="text" value="<? echo $row['test6TesterVol'];?>"> </td>
<td><input type="text" value="<? echo $row['test7TesterVol'];?>"> </td>
<td><input type="text" value="<? echo $row['test8TesterVol'];?>"> </td>
</tr>
<tr>
<td style="border:none; text-align: left;">Tester Accuracy: </td>
<td><input type="text" value="<? echo $row['test1Accuracy'];?>">% </td>
<td><input type="text" value="<? echo $row['test2Accuracy'];?>">% </td>
<td><input type="text" value="<? echo $row['test3Accuracy'];?>">% </td>
<td><input type="text" value="<? echo $row['test4Accuracy'];?>">% </td>
<td><input type="text" value="<? echo $row['test5Accuracy'];?>">% </td>
<td><input type="text" value="<? echo $row['test6Accuracy'];?>">% </td>
<td><input type="text" value="<? echo $row['test7Accuracy'];?>">% </td>
<td><input type="text" value="<? echo $row['test8Accuracy'];?>">% </td>
<td style="border:none;">Overall</td>
</tr>
<tr>
<td style="border:none; text-align: left;">Corrected Accuracy: </td>
<?php
$sum=0;
for($i=1; $i<=8; $i++){
if($row["test".$i."TesterVol"] == 0){
$row["test".$i."TesterVol"] = 0.001;
}
$testFormA = $row["test".$i."MeterVol"] / $row["test".$i."TesterVol"];
$testFormB = $testFormA * $row["test".$i."Accuracy"];
$testFinalForm = $testFormB;
$sum += $testFinalForm;
?>
<td><?php echo round($testFinalForm,3) ?>%</td>
<?php }
$average = $sum / 7 ;
?>
<td><?php echo round($average,5)?>% </td>
</tr>
</table>
</div>
<br>
<br>
</form>
I am at the very basic level of coding and I need help regarding this. You can post other links if there are any, related to this thing.
I want to get values from database dynamically on selection of city drop down and set it in a text box.
Any help will be appreciated.!!
enter image description here
<tr>
<td>
<label>City</label>
</td>
<td>
<select id="state" name="city" class="form-control" >
<?php
$sql = "SELECT city FROM service_point GROUP BY city";
$sel = mysql_query($sql);
// output data of each row
while($row = mysql_fetch_array($sel)) {
$city=$row['city'];
?>
<option value="<?php echo $row['city'] ?>">
<?php echo $row['city']; ?></option>
<?php }?>
</select>
</td>
</select>
</tr>
<tr>
<td> </td>
</tr>
<?php
include('config.php');
$s_name="";
$address="";
$phone_no="";
$email="";
$cperson="";
$city="";
$id=$_POST['city'];
$sql = "SELECT * FROM service_point where city = $id'' ";
$query = mysql_query($sql);
echo $sql;
while($row = mysql_fetch_array($query)){
?>
<tr>
<td> Name Of Service Point</td>
<td><input type="text" name="name" value="<?php echo $row['s_name'];?>"/></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>Address </td>
<td><textarea name="address" col="5" value="<?php echo $row['address'];?>"></textarea></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>Phone No</td>
<td><input type="text" name="phoneno" value="<?php echo $row[' phone_no'];?>"/></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>Email Id</td>
<td><input type="text" name="email" value="<?php echo $row['email'];?>"/></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>Contact Person</td>
<td><input type="text" name="cperson" value="<?php echo $row['cperson'];?>"/></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td></td>
<td align="center"><input type="submit" name="submit" value="submit"/><td>
</tr>
</table>
<?php }?>
</form>
Also, how can I access the <td> for each value?
This is my table in HTML:
<table class="inventory" style="float:left; position:relative;">
<tbody>
<tr>
<th>Name</th>
<th>Rate</th>
<th>OT</th>
<th>Leaves</th>
<th>Total</th>
</tr>
<tr>
<td>
<input type="text" placeholder="Name"/>
</td>
<td>
<input type="text" placeholder="Rate"/>
</td>
<td>
<input type="text" placeholder="OT"/>
</td>
<td>
<input type="text" placeholder="Leaves"/>
</td>
<td>
<input type="text" placeholder="Total"/>
</td>
</tr>
<tr>
<td>
<input type="text" placeholder="Name"/>
</td>
<td>
<input type="text" placeholder="Rate"/>
</td>
<td>
<input type="text" placeholder="OT"/>
</td>
<td>
<input type="text" placeholder="Leaves"/>
</td>
<td>
<input type="text" placeholder="Total"/>
</td>
</tr>
</tbody>
</table>
How can I add rows in my HTML table equal to the number of entries I have in Mysql DB?
I am assuming your database connection as $con. Place your database table name and column name in appropriate place.
<table class="inventory" style="float:left; position:relative;">
<tbody>
<tr>
<th>Name</th>
<th>Rate</th>
<th>OT</th>
<th>Leaves</th>
<th>Total</th>
</tr>
<?php
$query = mysqli_query($con,"SELECT * FROM tableName");
while($row = mysqli_fetch_array($query,MYSQLI_ASSOC))
{?>
<tr>
<td>
<input type="text" placeholder="Name" value="<?php echo $row['Name_Column_name']?>"/>
</td>
<td>
<input type="text" placeholder="Rate" value="<?php echo $row['Rate_Column_name']?>"/>
</td>
<td>
<input type="text" placeholder="OT" value="<?php echo $row['OT_Column_name']?>"/>
</td>
<td>
<input type="text" placeholder="Leaves" value="<?php echo $row['Leaves_Column_name']?>"/>
</td>
<td>
<input type="text" placeholder="Total" value="<?php echo $row['Total_Column_name']?>"/>
</td>
</tr>
<?php }?>
</tbody>
</table>
You can use this coding adn edit it as per your requirement
<table>
<tr>
<td>Name</td>
<td>Rate</td>
<td>OT</td>
<td>Leaves</td>
<td>Total</td>
</tr>
<?php
$total_row=mysql_num_rows(mysql_query("SELECT * FROM table_name"));
$q="SELECT * FROM table_name";
$run=mysql_query($q);
if($total_row > 0)
{
while($row1=mysql_fetch_assoc($run))
{
$Name=$row1['Name'];
$Rate=$row1['Rate'];
$OT=$row1['OT'];
$Leaves=$row1['Leaves'];
$Total=$row1['Total'];
?>
</tr>
<tr>
<td><?php echo $Name;?></td>
<td><?php echo $Rate;?></td>
<td><?php echo $OT;?></td>
<td><?php echo $Leaves;?></td>
<td><?php echo $Total;?></td>
</tr>
<?php }
}?>
</table>
Try with something like this:
$sql = "SELECT..."; //Add your query. Presumed you have 'name' column
$result = mysql_query($sql);
echo '<table class="inventory" style="float:left; position:relative;">';
echo '<thead>';
while ($row = mysql_fetch_assoc($result)) {
echo '<tr>';
echo '<th>'.$row["name"].'</th>';
echo '</tr>';
}
echo '</thead>';
echo '<tbody>';
while ($row = mysql_fetch_assoc($result)) {
echo '<tr>';
echo '<td>';
echo '<input type="text" placeholder="'.$row["name"].'"/>';
echo '</td>';
echo '</tr>';
}
echo '</tbody>';
echo '</table>';
Please look into this code unable to find out the actual error:
This is PHP upload code:
<?php
include_once("config.php");
if(isset($_GET['pro_id']))
{
$id=$_GET['pro_id'];
if(isset($_POST['submitBtn'])) {
$dept_id = $_POST['dept_id'];
$cat_id = $_POST['cat_id'];
/*$pro_id = $_POST['pro_id'];*/
$pro_name = $_POST['pro_name'];
$pro_desc = $_POST['pro_desc'];
$pro_spec = $_POST['pro_spec'];
$pro_price = $_POST['pro_price'];
$status = 'on';
$pro_keywords = $_POST['pro_keywords'];
//image names
$pro_image = $_FILES['pro_image']['name'];
//temp images names
$temp_image = $_FILES['pro_image']['tmp_name'];
if($dept_id=='' OR $cat_id=='' OR $pro_name=='' OR $pro_desc=='' OR $pro_spec=='' OR $pro_price=='' OR $pro_image=='' OR $pro_keywords=='')
{
echo "<script>alert('All the fields are mandatory')</script>";
exit();
}
else
{
//upload image to folder
move_uploaded_file($temp_image,"images/product_images/$pro_image");
$run_query1 = mysqli_query($login, "update products1 SET (dept_id,cat_id,pro_name,pro_desc,pro_spec,pro_price,pro_image,status,date,pro_keywords) values ( '$dept_id','$cat_id','$pro_name','$pro_desc','$pro_spec','$pro_price','$pro_image','$status','NOW()','$pro_keywords' WHERE pro_id='$id'");
if($run_query1)
{
echo "<script>alert('Product updated successfully')</script>";
exit();
}
else
{
echo "<script>alert('Errors')</script>";
}
} }
$query1 = mysqli_query($login, "select * from products1 where pro_id='$id'");
$query2 = mysqli_fetch_array($query1);
?>
This the form Part where data retrieve from table and when click on the update button nothing happened and page is redirected to view data page and showing the old data:
<form action="ViewProduct.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<table width="650" border="0">
<tr>
<td width="183" align="right">Department:</td>
<th width="231" align="left">
<select name="dept_id" id="dept_id">
<option>Select Department</option>
<?php
$result=dept_show();
while($row=mysqli_fetch_assoc($result))
{
echo "<option value='{$row['dept_id']}'>{$row['dept_name']}</option>";
}
?>
</select></th></tr>
<tr>
<td width="183" align="right">Catagory</td>
<th width="231" align="left">
<select name="cat_id" id="cat_id">
<option>Select Catagory</option>
<?php
$result1=cat_show();
while($row=mysqli_fetch_assoc($result1))
{
echo "<option value='{$row['cat_id']}'>{$row['cat_name']}</option>";
}
?>
</select></th></tr>
<tr>
<!--<td width="231"><input type="hidden" name="pro_id" id="pro_id" value="<t?php echo $pro_id; ?>" /></td>-->
</tr>
<tr>
<td align="right">Product Name/Model:</td>
<td><input type="text" name="pro_name" id="pro_name" value="<?php echo $query2['pro_name']; ?>" /></td>
</tr>
<tr>
<td align="right">Product Description:</td>
<td><textarea type="textarea" name="pro_desc" id="pro_desc" cols="45" rows="5"><?php echo $query2['pro_desc']; ?></textarea></td>
</tr>
<tr>
<td align="right">Products Specification:</td>
<td><textarea type="textarea" name="pro_spec" id="pro_spec" cols="45" rows="5"><?php echo $query2['pro_spec']; ?></textarea></td>
</tr>
<tr>
<td align="right">Product Price:</td>
<td><input type="text" name="pro_price" id="pro_price" value="<?php echo $query2['pro_price']; ?>" /></td>
</tr>
<tr>
<td align="right">Product Image:</td>
<td><input type="file" name="pro_image" id="pro_image" value="<?php echo $query2['pro_image']; ?>" /></td>
</tr>
<tr>
<td></td>
<td><input size="45" type="text" name="text" id="text" value="<?php echo $query2['pro_image']; ?>" /></td>
</tr>
<tr>
<td align="right">Keywords:</td>
<td><input size="45" type="text" name="pro_keywords" id="pro_keywords" value="<?php echo $query2['pro_keywords']; ?>" /></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="submitBtn" id="submit" value="Update" /></td>
</tr>
</table>
</form>
</div> <?php } ?>
</td>
</tr>
</table>
</div>
Form method is POST and you are using GET method in if loop
if(isset($_GET['pro_id']))
Use POST here.
I have made the changes in you complete code. Use this code and if required made the changes (if issues arrived)
PHP code
<?php
include_once("config.php");
if(isset($_POST['submitBtn']))
{
$dept_id = $_POST['dept_id'];
$cat_id = $_POST['cat_id'];
$pro_id = $_POST['pro_id'];*/
$pro_name = $_POST['pro_name'];
$pro_desc = $_POST['pro_desc'];
$pro_spec = $_POST['pro_spec'];
$pro_price = $_POST['pro_price'];
$status = 'on';
$pro_keywords = $_POST['pro_keywords'];
//image names
$pro_image = $_FILES['pro_image']['name'];
//temp images names
$temp_image = $_FILES['pro_image']['tmp_name'];
if($dept_id=='' OR $cat_id=='' OR $pro_name=='' OR $pro_desc=='' OR $pro_spec=='' OR $pro_price=='' OR $pro_image=='' OR $pro_keywords=='')
{
echo "<script>alert('All the fields are mandatory')</script>";
exit();
}
else
{
//upload image to folder
move_uploaded_file($temp_image,"images/product_images/$pro_image");
$run_query1 = mysqli_query($login, "update products1 SET (dept_id,cat_id,pro_name,pro_desc,pro_spec,pro_price,pro_image,status,date,pro_keywords) values ( '$dept_id','$cat_id','$pro_name','$pro_desc','$pro_spec','$pro_price','$pro_image','$status','NOW()','$pro_keywords' WHERE pro_id='$id'");
if($run_query1)
{
echo "<script>alert('Product updated successfully')</script>";
exit();
}
else
{
echo "<script>alert('Errors')</script>";
}
}
}
$query2 = array();
if(isset($_GET['pro_id']))
{
$id=$_GET['pro_id'];
$query1 = mysqli_query($login, "select * from products1 where pro_id='$id'");
$query2 = mysqli_fetch_array($query1);
}
?>
HTML Code
<form action="ViewProduct.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<table width="650" border="0">
<tr>
<td width="183" align="right">Department:</td>
<th width="231" align="left">
<select name="dept_id" id="dept_id">
<option>Select Department</option>
<?php
$result=dept_show();
while($row=mysqli_fetch_assoc($result))
{
echo "<option value='{$row['dept_id']}'>{$row['dept_name']}</option>";
}
?>
</select></th></tr>
<tr>
<td width="183" align="right">Catagory</td>
<th width="231" align="left">
<select name="cat_id" id="cat_id">
<option>Select Catagory</option>
<?php
$result1=cat_show();
while($row=mysqli_fetch_assoc($result1))
{
echo "<option value='{$row['cat_id']}'>{$row['cat_name']}</option>";
}
?>
</select></th></tr>
<tr>
<td width="231"><input type="hidden" name="pro_id" id="pro_id" value="<t?php echo $pro_id; ?>" /></td>
</tr>
<tr>
<td align="right">Product Name/Model:</td>
<td><input type="text" name="pro_name" id="pro_name" value="<?php echo $query2['pro_name']; ?>" /></td>
</tr>
<tr>
<td align="right">Product Description:</td>
<td><textarea type="textarea" name="pro_desc" id="pro_desc" cols="45" rows="5"><?php echo $query2['pro_desc']; ?></textarea></td>
</tr>
<tr>
<td align="right">Products Specification:</td>
<td><textarea type="textarea" name="pro_spec" id="pro_spec" cols="45" rows="5"><?php echo $query2['pro_spec']; ?></textarea></td>
</tr>
<tr>
<td align="right">Product Price:</td>
<td><input type="text" name="pro_price" id="pro_price" value="<?php echo $query2['pro_price']; ?>" /></td>
</tr>
<tr>
<td align="right">Product Image:</td>
<td><input type="file" name="pro_image" id="pro_image" value="<?php echo $query2['pro_image']; ?>" /></td>
</tr>
<tr>
<td></td>
<td><input size="45" type="text" name="text" id="text" value="<?php echo $query2['pro_image']; ?>" /></td>
</tr>
<tr>
<td align="right">Keywords:</td>
<td><input size="45" type="text" name="pro_keywords" id="pro_keywords" value="<?php echo $query2['pro_keywords']; ?>" /></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="submitBtn" id="submit" value="Update" /></td>
</tr>
</table>
</form>
</div> <?php } ?>
</td>
</tr>
</table>
Your pro_id field is commented out in your HTML using <!-- and -->, so the following never is true:
if(isset($_GET['pro_id']))
Also, you have a mismatch between your form method POST and $_GET that you are looking for.
Your query of update is correct? I think you must use
UPDATE products1 SET dept_id='$dept_id',cat_id ='$cat_id'... the rest of values
WHERE pro_id='$id'
And verify if your dept_id is INT as well cat_id, so if they are INT you don't need ''
UPDATE products1 SET dept_id=$dept_id,cat_id =$cat_id
Try to do this steps:
First thing comment out this line,
<!--<td width="231"><input type="hidden" name="pro_id" id="pro_id" value="<t?php echo $pro_id; ?>" /></td>-->
next step,
you are sending data using POST i.e. (form method="post"), so use this
if(isset($_POST['pro_id'])) , then comment out $pro_id = $_POST['pro_id'];
you will get $pro_id value.
I don't know why but my table cuts off right after the second <td> tag... can anyone help, I have constantly looked over it over and over. Can someone help me find where the problem is?
<tr>
<td>Username:</td>
<td>
<input name="username" type="text" value='<?
if($form->value("username")==""){
echo($req_user_info["username"]);
}else{
echo $form->value("username");
}
?>' size="56" maxlength="30">
</td>
<td>
<? echo($form->error("username")); ?>
</td>
</tr>
<tr>
<td>New Password:</td>
<td>
<input name="newpass" type="password" value='<?
echo($form->value("newpass"));
?>' size="56" maxlength="30">
</td>
<td>
<? echo($form->error("newpass")); ?>
</td>
</tr>
Btw, that code is only the first two rows.
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
?>
<form action="adminprocess.php" method="POST">
<table align="left" border="0" cellspacing="0" cellpadding="3">
<tr>
<td>Username:</td>
<td>
<input name="username" type="text" value='<?php
if($form->value("username")==""){
echo($req_user_info["username"]);
}else{
echo $form->value("username");
}
?>' size="56" maxlength="30">
</td>
<td>
<?php echo($form->error("username")); ?>
</td>
</tr>
<tr>
<td>New Password:</td>
<td>
<input name="newpass" type="password" value='<?php
echo($form->value("newpass"));
?>' size="56" maxlength="30">
</td>
<td>
<?php echo($form->error("newpass")); ?>
</td>
</tr>
<tr>
<td>Confirm New Password:</td>
<td><input name="conf_newpass" type="password" value='
<?php echo $form->value("newpass"); ?>' size="56" maxlength="30"></td>
<td><?php echo $form->error("newpass"); ?></td>
</tr>
</tr>
<td>Edit motto:</td>
<td><input type="text" size="56" name="motto" value='<?php
if($form->value("motto") == ""){
echo $req_user_info['motto'];
}else{
echo $form->value("motto");
}
?>'></td>
<tr>
<tr>
<td>Edit profile bio:</td>
<td><textarea cols="40" rows="10" name="profile" value=""><?php
if($form->value("profile") == ""){
echo $req_user_info['profile'];
}else{
echo $form->value("profile");
}
?></textarea></td>
<tr>
<tr>
<td>Email:</td>
<td><input name="email" type="text" value='
<?php
if($form->value("email") == ""){
echo $req_user_info["email"];
}else{
echo $form->value("email");
}
?>' size="56" maxlength="50">
</td>
<td><?php echo $form->error("email"); ?></td>
</tr>
<tr>
<td>User level:</td>
<td><input name="userlevel" type="text" value='
<?php
if($form->value("userlevel") == ""){
echo $req_user_info["userlevel"];
}else{
echo $form->value("userlevel");
}
?>' size="4" maxlength="10"></td>
<td><?php echo $form->error("userlevel"); ?></td>
</tr>
<tr><td align="right">
<input type="hidden" name="subedit" value="1">
<input type="hidden" name="usertoedit" value="<?php echo $usertoedit; ?>">
<input type="submit" name="button" value="Edit Account">
</td>
<td colspan="2" style="text-align:right;">
<input type="submit" name="button" value="Delete" onclick="return confirm ('Are you sure you want to delete this user, this cannot be undone?\n\n' + 'Click OK to continue or Cancel to Abort!')">
</td>
</tr>
</table>
</form>
I've changed your syntax a little..
<tr>
<td>Username:</td>
<td><input name="username" type="text" value="<?php echo htmlspecialchars(($form->value("username")=="" ? $req_user_info["username"] : $form->value("username"))); ?>" size="56" maxlength="30"></td>
<td><?php echo $form->error("username"); ?></td>
</tr>
<tr>
<td>New Password:</td>
<td><input name="newpass" type="password" value="<?php echo htmlspecialchars($form->value("newpass")); ?>" size="56" maxlength="30"></td>
<td><?php echo $form->error("newpass"); ?></td>
</tr>
For additional php error logging, put this at the top of the page:
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
?>