I am having trouble grabbing the values from the form once processed. I need your help.
function updateUser($table, $id) { if($_POST) { processUpdate($table, $id); } else { updateForm($table, $id); } } function processUpdate($table, $id) { print $table; //testing print $id; //testing $email=addslashes($HTTP_POST_VARS['email']); $lname=addslashes($HTTP_POST_VARS['lname']); $fname=addslashes($HTTP_POST_VARS['fname']); print $lname; //which table do we update switch($table) { case 'maillist': $result = mysql_query('UPDATE $table SET email='$email', lname='$lname', fname='$fname' WHERE id='$id'') or die(mysql_error()); break; } }
The function updateForm($table, $id); just outputs the form, has email, lname, fname fields. And when you process the form, the action is the same, w/ the table and id being passed thru the URL, so it GET’s the id and table that way, and for lname, fname, and email, it should grab it via post.
EDIT: this is what the form tag is for the updateForm function: <form method='post' action='?mode=upd&id='.$id.'&table='.$table.''>
But for some reason, it does not post the values.
Is the method attribute of the form set to post?
And are all of the input’s name attribute set right?
Have you looked at the html output to make sure that there were no syntax errors? Also, try using
$_POSTinstead of
$HTTP_POST_VARS