PHP Login System with Admin Features

Would you like to react to this message? Create an account in a few clicks or log in to continue.
PHP Login System with Admin Features

This forum was created to talk about the PHP Login System with admin features created by jpmaster77 on evolt's website


2 posters

    Adding new fields Part 2

    Fred-Eric
    Fred-Eric


    Number of posts : 63
    Registration date : 2007-05-13

    Adding new fields Part 2 Empty Adding new fields Part 2

    Post  Fred-Eric Wed Feb 25, 2009 4:06 pm

    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
    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
    mattastic
    mattastic


    Number of posts : 25
    Registration date : 2009-10-11

    Adding new fields Part 2 Empty Re: Adding new fields Part 2

    Post  mattastic Mon Oct 12, 2009 10:45 am

    i had a slight problem figuring everything out but i got it to work, great tutorial

      Current date/time is Fri May 17, 2024 7:41 am