doutangu4671 2016-02-01 14:22
浏览 33

如何在登录页面上添加第一个和第二个名称字段

I would like to know the code to add first and second name fields into my phpDolphin login page and also make them display on the person's profile. I've already tried to add the fields, but my coding is so wrong.

At the moment, the profile displays a username of which the individual entered upon signing up. I want the profile to display the first and second name entered at login page instead of the username.

I have added this code into a file called classes.php :

public $firstname;                              // The inserted firstname
public $secondname;                             // The inserted secondname

and i have entered this code into the file where the login page is coded:

   <input type="text" id="short" name="firstname" placeholder="{$lng->firstname" />
                                    <input type="text" id="short" name="secondname" placeholder="{$lng->secondname" />

Remember, i didn't code this myself, its a script called phpDolphin, and i'm just trying to add to it!

I would very much appreciate some help. Thanks in advance, Will.

If you would like to see the site which contains the login page, heres the link: http://www.social.flamboyantent.co.uk/ EDIT

there's over 4 thousand lines of code in classes.php alone. If you would like the full file let me know.

  function getProfile($start, $value) {
$profile = $this->profile_data;
$this->profile_id = $profile['idu'];

// If the username exist
if(!empty($profile['idu'])) {
  $relationship = $this->verifyRelationship($this->id, $this->profile_id, 0);

  // Check privacy
  switch($profile['private']) {
    case 0:
      break;
    case 1:
      // Check if the username is not same with the profile
      if($this->profile !== $this->username) {
        return $this->showError('profile_private');
      }
      break;
    case 2:
      // Check relationship
      if(!$relationship) {
        return $this->showError('profile_semi_private');
      }
      break;
  }

  // Allowed types
  $allowedType = $this->listTypes('profile');
  $allowedDates = $this->listDates('profile');

  // If the $start value is 0, empty the query;
  if($start == 0) {
    $start = '';
  } else {
    // Else, build up the query
    $start = 'AND messages.id < \''.$this->db->real_escape_string($start).'\'';
  }

  // Decide if the query will include only public messages or not
  $public = ($this->username == $this->profile) ? '' : 'AND messages.public = 1';
  if(in_array($value, $allowedType)) {
    $query = sprintf("SELECT * FROM messages, users WHERE messages.uid = '%s' AND messages.type = '%s' AND messages.uid = users.idu %s %s ORDER BY messages.id DESC LIMIT %s", $this->db->real_escape_string($profile['idu']), $this->db->real_escape_string($value), $public, $start, ($this->per_page + 1));
    $value = '\''.$value.'\'';
  } elseif(in_array($value, $allowedDates)) {
    $query = sprintf("SELECT * FROM messages, users WHERE messages.uid = '%s' AND extract(YEAR_MONTH from `time`) = '%s' AND messages.uid = users.idu %s %s ORDER BY messages.id DESC LIMIT %s", $this->db->real_escape_string($profile['idu']), $this->db->real_escape_string($value), $public, $start, ($this->per_page + 1));
    $value = '\''.$value.'\'';
  } else {
    $query = sprintf("SELECT * FROM messages, users WHERE messages.uid = '%s' AND messages.uid = users.idu %s %s ORDER BY messages.id DESC LIMIT %s", $this->db->real_escape_string($profile['idu']), $public, $start, ($this->per_page + 1));
    $value = '\'\'';
  }
  return $this->getMessages($query, 'loadProfile', $value);
} else {
  return $this->showError('profile_not_exist');
}


 }

  function getSubscriptionsList() {
    // The query to select the subscribed users
    $query = sprintf("SELECT `leader` FROM `relations` WHERE `subscriber` = '%s'", $this->db->real_escape_string($this->id));

    // Run the query
    $result = $this->db->query($query);

    // The array to store the subscribed users
    $subscriptions = array();
    while($row = $result->fetch_assoc()) {
      $subscriptions[] = $row['leader'];
    }

    // Close the query
    $result->close();

    // Return the subscriptions list (e.g: 13,22,19)
    return implode(',', $subscriptions);
  }

  public function profileData($username = null, $id = null) {
    // The query to select the profile
    // If the $id is set (used in Subscribe function for profiels) then search for the ID
    if($id) {
      $query = sprintf("SELECT `idu`, `username`, `email`, `first_name`, `last_name`, `location`, `website`, `bio`, `date`, `facebook`, `twitter`, `gplus`, `image`, `private`, `background`, `privacy`, `born`, `cover`, `verified`, `gender`, `email_new_friend` FROM `users` WHERE `idu` = '%s'", $this->db->real_escape_string($id));
    } else {
      $query = sprintf("SELECT `idu`, `username`, `email`, `first_name`, `last_name`, `location`, `website`, `bio`, `date`, `facebook`, `twitter`, `gplus`, `image`, `private`, `background`, `privacy`, `born`, `cover`, `verified`, `gender`, `email_new_friend` FROM `users` WHERE `username` = '%s'", $this->db->real_escape_string($username));
    }

    // Run the query
    $result = $this->db->query($query);

    return $result->fetch_assoc();
  }

  function fetchProfile($profile) {
    global $LNG, $CONF;
    $coverImage = ((!empty($profile['cover'])) ? $profile['cover'] : 'default.png');
    $coverAvatar = ((!empty($profile['image'])) ? $profile['image'] : 'default.png');
    $cover = '<div class="twelve columns">
          <div class="cover-container">
            <div class="cover-content">
              <a onclick="gallery(\''.$coverImage.'\', \''.$profile['idu'].$profile['username'].'\', \'covers\')" id="'.$coverImage.'"><div class="cover-image" style="background-position: center; background-image: url('.$this->url.'/thumb.php?src='.((!empty($profile['cover'])) ? $profile['cover'] : 'default.png').'&w=900&h=300&t=c)">
              </div></a>
              <div class="cover-description">
                <div class="cover-avatar-content">
                  <div class="cover-avatar">
                    <a onclick="gallery(\''.$coverAvatar.'\', \''.$profile['idu'].$profile['username'].'\', \'avatars\')" id="'.$coverAvatar.'"><span id="avatar'.$profile['idu'].$profile['username'].'"><img src="'.$this->url.'/thumb.php?src='.$coverAvatar.'&t=a&w=150&h=150" /></span></a>
                  </div>
                </div>
                <div class="cover-description-content">
                  <span id="author'.$profile['idu'].$profile['username'].'"></span><span id="time'.$profile['idu'].$profile['username'].'"></span><div class="cover-username"><a href="'.$this->url.'/index.php?a=profile&u='.$profile['username'].'">'.realName($profile['username'], $profile['first_name'], $profile['last_name']).'</a>'.((!empty($profile['verified'])) ? '<img src="'.$this->url.'/'.$CONF['theme_url'].'/images/icons/verified.png" title="'.$LNG['verified_user'].'" />' : '').'</div>
                  <div class="cover-description-buttons"><div id="subscribe'.$profile['idu'].'">'.$this->getSubscribe(null, null, null).'</div>'.$this->chatButton($profile['idu'], $profile['username'], 1).'</div>
                </div>
              </div>
            </div>
          </div>
        </div>';
    return $cover;
  }

  function getProfileCard($profile) {
    global $LNG, $CONF;
    $coverImage = ((!empty($profile['cover'])) ? $profile['cover'] : 'default.png');
    $coverAvatar = ((!empty($profile['image'])) ? $profile['image'] : 'default.png');
    $subscribe = $this->getSubscribe(null, null, null);
    $card = '
      <div class="profile-card-cover"><img src="'.$this->url.'/thumb.php?src='.((!empty($profile['cover'])) ? $profile['cover'] : 'default.png').'&w=900&h=300&t=c"></div>
      <div class="profile-card-avatar">
        <a href="'.$this->url.'/index.php?a=profile&u='.$profile['username'].'"><img src="'.$this->url.'/thumb.php?src='.$coverAvatar.'&t=a&w=112&h=112" /></a>
      </div>
      <div class="profile-card-info">
        <a href="'.$this->url.'/index.php?a=profile&u='.$profile['username'].'"><span id="author'.$profile['idu'].$profile['username'].'"></span><span id="time'.$profile['idu'].$profile['username'].'"></span><div class="cover-username">'.realName($profile['username'], $profile['first_name'], $profile['last_name']).''.((!empty($profile['verified'])) ? '<img src="'.$this->url.'/'.$CONF['theme_url'].'/images/icons/verified.png" title="'.$LNG['verified_user'].'" />' : '').'</div></a>
      </div>
      '.((!empty($profile['bio'])) ? '<div class="profile-card-divider"></div><div class="profile-card-bio">'.$profile['bio'].'</div>' : '').'
      '.((!empty($subscribe)) ? '
      <div class="profile-card-divider"></div>
      <div class="profile-card-buttons"><div class="profile-card-buttons-container"><div id="subscribe'.$profile['idu'].'">'.$subscribe.'</div>'.$this->chatButton($profile['idu'], $profile['username'], 1).'</div></div>' : '').'
    ';
    return $card;
  }

  function fetchProfileWidget($username, $name, $image) {
    global $LNG;
    $widget =  '<div class="sidebar-container widget-welcome">
            <div class="sidebar-content">
              <div class="sidebar-header">'.$LNG['welcome'].'</div>
              <div class="sidebar-inner">
                <div class="sidebar-avatar"><a href="'.$this->url.'/index.php?a=profile&u='.$username.'"><img src="'.$this->url.'/thumb.php?src='.$image.'&t=a&w=50&h=50" /></a></div>
                <div class="sidebar-avatar-desc">
                  <a href="'.$this->url.'/index.php?a=profile&u='.$username.'">'.((!empty($name) ? $name : $username)).'</a>
                  <div class="sidebar-avatar-edit"><a href="'.$this->url.'/index.php?a=settings">'.$LNG['admin_ttl_edit_profile'].'</a></div>
                </div>
              </div>
            </div>
          </div>';
    return $widget;
  }

Code for profile from profile.php

    <?php
function PageMain() {
    global $TMPL, $LNG, $CONF, $db, $loggedIn, $settings;

if(isset($_SESSION['username']) && isset($_SESSION['password']) || isset($_COOKIE['username']) && isset($_COOKIE['password'])) {    
    $verify = $loggedIn->verify();

    if(empty($verify['username'])) {
        // If fake cookies are set, or they are set wrong, delete everything and redirect to home-page
        $loggedIn->logOut();
        header("Location: ".$CONF['url']."/index.php?a=welcome");
    }

    // If the $_GET user is empty, define default user as current logged in user, else redirect to home-pag
    if($_GET['u'] == '') {
        $_GET['u'] = (!empty($verify['username']) ? $verify['username'] : header("Location: ".$CONF['url']."/index.php?a=welcome"));
    }

    // If the current user is the same with the viewed profile, display the Message Form
    if($verify['username'] == $_GET['u']) {
        $skin = new skin('shared/top'); $top = '';

        $TMPL['theme_url'] = $CONF['theme_url'];
        $TMPL['private_message'] = $verify['privacy'];
        $TMPL['avatar'] = $verify['image'];
        $TMPL['url'] = $CONF['url'];

        $top = $skin->make();
    }
}

// Start displaying the Feed
$feed = new feed();
$feed->db = $db;
$feed->url = $CONF['url'];
$feed->user = $verify;
$feed->id = $verify['idu'];
$feed->username = $verify['username'];
$feed->per_page = $settings['perpage'];
$feed->time = $settings['time'];
$feed->censor = $settings['censor'];
$feed->smiles = $settings['smiles'];
$feed->c_per_page = $settings['cperpage'];
$feed->c_start = 0;
$feed->l_per_post = $settings['lperpost'];

if($verify['username']) {
    $feed->updateStatus($verify['offline']);
}

// If the $_GET user is empty, define default user as current logged in user, else redirect to home-pag
if($_GET['u'] == '') {
    $_GET['u'] = (!empty($feed->username) ? $feed->username : header("Location: ".$CONF['url']."/index.php?a=welcome"));
}

$feed->profile = $_GET['u'];
$feed->profile_data = $feed->profileData($_GET['u']);
$feed->subscriptionsList = $feed->getSubs($feed->profile_data['idu'], 0, null);
$feed->subscribersList = $feed->getSubs($feed->profile_data['idu'], 1, null);
// $feed->image = $verify['image'];

$TMPL_old = $TMPL; $TMPL = array();
$skin = new skin('shared/rows'); $rows = '';

if(empty($_GET['filter'])) {
    $_GET['filter'] = '';
}
// Allowed types
list($timeline, $message) = $feed->getProfile(0, $_GET['filter']);

if($_GET['r'] == 'subscriptions') {
    if($message !== 1) {
        $top = ''; // Hide the message form
        $feed->s_per_page = $settings['sperpage'];
        $feed->subsList = $feed->getSubs($feed->profile_data['idu'], 0, 0);
        $TMPL['messages'] = $feed->listSubs(0);
        $x = 1;
    } else {
        $TMPL['messages'] = $timeline;
    }
    $title = $LNG['subscriptions'];
} elseif($_GET['r'] == 'subscribers') {
    if($message !== 1) {
        $top = ''; // Hide the message form
        $feed->s_per_page = $settings['sperpage'];
        $feed->subsList = $feed->getSubs($feed->profile_data['idu'], 1, 0);
        $TMPL['messages'] = $feed->listSubs(1);
        $x = 1;
    } else {
        $TMPL['messages'] = $timeline;
    }
    $title = $LNG['subscribers'];
} elseif($_GET['r'] == 'likes') {
    if($message !== 1) {
        $top = ''; // Hide the message form
        $TMPL['messages'] = $feed->getLikes(0, 1);
        $x = 1;
    } else {
        $TMPL['messages'] = $timeline;
    }
    $title = $LNG['likes'];
} else {
    $TMPL['messages'] = $timeline;
}

$rows = $skin->make();

$skin = new skin('profile/sidebar'); $sidebar = '';
// If the username doesn't exist
if($message !== 1) {
    $TMPL['about'] = $feed->fetchProfileInfo($feed->profileData($_GET['u']));
    $TMPL['sidebar'] = $feed->sidebarTypes($_GET['filter'], 'profile');
    $TMPL['dates'] = $feed->sidebarDates($_GET['filter'], 'profile');

    $TMPL['places'] = $feed->sidebarPlaces($feed->profile_data['idu']);

    $TMPL['subscriptions'] = $feed->sidebarSubs(0, $subscriptions, 0);
    $TMPL['subscribers'] = $feed->sidebarSubs(1, $subscribers, 0);
    $TMPL['ad'] = generateAd($settings['ad4']);
} else {
    $skin = new skin('profile/sidebar'); $sidebar = '';
    $TMPL['ad'] = generateAd($settings['ad4']);
}
$sidebar = $skin->make();

$TMPL = $TMPL_old; unset($TMPL_old);
$TMPL['top'] = $top;
$TMPL['rows'] = $rows;
$TMPL['sidebar'] = $sidebar;
$TMPL['cover'] = $feed->fetchProfile($feed->profile_data);

if(isset($_GET['logout']) == 1) {
    $loggedIn->logOut();
    header("Location: ".$CONF['url']."/index.php?a=welcome");
}

$TMPL['url'] = $CONF['url'];
$TMPL['title'] = (!empty($title) ? $title : $LNG['title_profile']).' - '.realName($_GET['u'], $feed->profile_data['first_name'], $feed->profile_data['last_name'], 1).' - '.$settings['title'];

if($x) {
    $skin = new skin('shared/timeline_x');
} else {
    $skin = new skin('shared/timeline');
}


return $skin->make();
}
?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题