FORMS
Posted: Fri May 28, 2010 12:41 am
I'm developing a website where a user can update their information in the database. When the user first goes to the update page, the function displayUpdateForm is executed. This allows the user to type in the Id for which record they want to update in the database. After they submit the form, the actionUpdateForm function is executed which uses a foreach statement to print all the users information into a form with text fields. Then after they are finished updating the information they press submit one more time which executes the processUpdateForm function and thatll submit the updated information to the database. The problem I'm having is after the user submits the updated information from the actionUpdateForm, the only value being passed in the post array is [submit]=>update. I've looked at the view source in the browser and none of the text fields inside the foreach statement are there even though they are displayed on the screen. Can anyone see where my code is going wrong?
Code: Select all
<?php
function displayUpdateForm($message=''){
userAccess();
print("<div class=\"pageSubHeader\">");
print("Update Record");
print("</div>");
print($message);
print("<form action=\"index.php?update\" method=\"POST\"");
print("<input type=\"Text\" name=\"Id\"");
print("<input type=\"Submit\" name=\"Submit\" value=\"Submit\">");
print("</form>");
}
function actionUpdateForm(){
checkNull();
checkUserExist();
$query="select * from user where Id='".$_POST["Id"]."'";
$result=mysql_query($query) or die("ERROR IN QUERY");
$row=mysql_fetch_row($result);
print("<form action=\"index.php?update\" method=\"POST\">");
foreach($row as $value){
$column=mysql_fetch_field($_POST["result"]);
print(ucfirst($column->name).": ");
print("<input type=\"text\" value=\"$value\">");
print("<br />");
}
print("<input type=\"Submit\" name=\"Submit\" value=\"Update\">");
print("</form>");
}
function processUpdateForm(){
//Debug
print_r($_POST);
}