This post is the step 2 for adding new input in form register.
Then after having added new fields into the login system, it's time to view those change when we are logged:
1- open userinfo.php for editing, modified the form to show new input field creation
2- open useredit.php for editing, modified the form to show new input field creation
3- open process.php for editing, add arguments for $session->editaccount class function.
4- open session.php for editing, add arguments to the function
4.1- Validate errors
4.2- Update the DataBase with the new informations
that's it...
video tutorial
Then after having added new fields into the login system, it's time to view those change when we are logged:
1- open userinfo.php for editing, modified the form to show new input field creation
- Code:
/* Firstname */
echo "<b>Firstname:</b> ".$req_user_info['firstname']."<br>";
2- open useredit.php for editing, modified the form to show new input field creation
- Code:
<tr>
<td>Firstname:</td>
<td><input type="text" name="firstname" maxlength="32" value="
<?
if($form->value("firstname") == ""){
echo $session->userinfo['firstname'];
}else{
echo $form->value("firstname");
}
?>">
</td>
<td><? echo $form->error("firstname"); ?></td>
</tr>
3- open process.php for editing, add arguments for $session->editaccount class function.
- Code:
/**
* procEditAccount - Attempts to edit the user's account
* information, including the password, which must be verified
* before a change is made.
*/
function procEditAccount(){
global $session, $form;
/* Account edit attempt */
$retval = $session->editAccount($_POST['curpass'], $_POST['newpass'], $_POST['email'], $_POST['firstname']);
/* Account edit successful */
if($retval){
$_SESSION['useredit'] = true;
header("Location: ".$session->referrer);
}
/* Error found with form */
else{
$_SESSION['value_array'] = $_POST;
$_SESSION['error_array'] = $form->getErrorArray();
header("Location: ".$session->referrer);
}
}
4- open session.php for editing, add arguments to the function
- Code:
/**
* editAccount - Attempts to edit the user's account information
* including the password, which it first makes sure is correct
* if entered, if so and the new password is in the right
* format, the change is made. All other fields are changed
* automatically.
*/
function editAccount($subcurpass, $subnewpass, $subemail, $subfirstname){
........
4.1- Validate errors
- Code:
/*Firstname error checking */
$field = "firstname";
if(!$subfirstname || strlen($subfirstname = trim($subfirstname)) == 0){
$form->setError($field, "* firstname not entered");
}
$subfirstname = stripslashes($subfirstname);
4.2- Update the DataBase with the new informations
- Code:
/* Change Email */
if($subfirstname){
$database->updateUserField($this->username,"firstname",$subfirstname);
}
that's it...
video tutorial