Chris920 0 Light Poster

Not sure if that is the correct title, but I created an additional field in the users profile. I want to add that field with the option to change that field (its a drop down) on the main homepage as well as profile page. It would be the exact same functionality, but on the homepage as well. How would I do that? Would i use the php variable with the database field, or copy the html source code into the html editor?

This is what one of the guys said for me to do, but I am still a bit lost.

you would need to modify the query in home.php to include your new field so you can then output the information. Then you would edit the html counterpart (in this case home.html which is in your skin folder) and output the information. The editing part could be a simple [Edit] link which if clicked would send the user to the edit profile page for the related category which the field is in. Although you would need to include a simple query in home.php to get the field cat id from the profile fields table.

The issue is I do not want it redirecting to the profile edit page. I want it to be changed directly from the home page.

Here is profile_edit.php

require 'includes/common.inc.php';
require _BASEPATH_.'/includes/user_functions.inc.php';
check_login_member('auth');

$tpl=new phemplate(_BASEPATH_.'/skins_site/'.get_my_skin().'/','remove_nonjs');

$cid=1;
$used_fields=array();
if (isset($_SESSION['topass']['input'])) {
    $user_details=&$_SESSION['topass']['input'];
    $user_details=sanitize_and_format($user_details,TYPE_STRING,FORMAT_STRIP_MQ);
    $cid=$user_details['pcat_id'];
    foreach ($_pcats[$cid]['fields'] as $field_id) {
        if ($_pfields[$field_id]->config['editable']) {
            $used_fields[]=$field_id;
            $_pfields[$field_id]->set_value($user_details,false);
        }
    }
    unset($_SESSION['topass']['input']);
} elseif (!empty($_GET['cid'])) {
    $cid=(int)$_GET['cid'];

    if (!isset($_pcats[$cid])) {
        $cid=1;
    }
    $query='SELECT 1';
    foreach ($_pcats[$cid]['fields'] as $field_id) {
        if ($_pfields[$field_id]->config['editable']) {
            $query.=','.$_pfields[$field_id]->query_select();
            $used_fields[]=$field_id;
        }
    }
    $query.=" FROM `{$dbtable_prefix}user_profiles` WHERE `fk_user_id`=".$_SESSION[_LICENSE_KEY_]['user']['user_id'];
    if (!($res=@mysql_query($query))) {trigger_error(mysql_error(),E_USER_ERROR);}
    if (mysql_num_rows($res)) {
        $user_details=mysql_fetch_assoc($res);
        for ($i=0;isset($used_fields[$i]);++$i) {
            $_pfields[$used_fields[$i]]->set_value($user_details,false);
        }
        unset($user_details);
    }
}

$tplvars['pcat_name']=$_pcats[$cid]['pcat_name'];
$tplvars['pcat_id']=$cid;
$loop=array();
for ($i=0;isset($used_fields[$i]);++$i) {
    $field=&$_pfields[$used_fields[$i]];
    $loop[$i]['label']=$field->config['label'];
    $loop[$i]['dbfield']=$field->config['dbfield'];
    $loop[$i]['required']=isset($field->config['required']) ? true : false;
    $loop[$i]['help_text']=$field->config['help_text'];
    $loop[$i]['js']=$field->edit_js();
    if (isset($user_details['error_'.$field->config['dbfield']])) {
        $loop[$i]['class_error']=$user_details['error_'.$field['dbfield']];
    }
    $loop[$i]['field']=$field->edit($i+4);
}
$output['lang_69']=sanitize_and_format($GLOBALS['_lang'][69],TYPE_STRING,$__field2format[TEXT_DB2DISPLAY]);
unset($user_details);

$tpl->set_file('content','profile_edit.html');
$tpl->set_var('output',$output);
$tpl->set_var('tplvars',$tplvars);
$tpl->set_loop('loop',$loop);
$tpl->process('content','content',TPL_LOOP | TPL_OPTLOOP);
$tpl->drop_loop('loop');
unset($loop);

$tplvars['title']=$GLOBALS['_lang'][141].' - '.$_pcats[$cid]['pcat_name'];
$tplvars['page_title']='<a href="'.$tplvars['relative_url'].'my_profile.php">'.$GLOBALS['_lang'][141].'</a> - '.$_pcats[$cid]['pcat_name'];
$tplvars['page']='profile_edit';
$tplvars['css']='profile_edit.css';
if (is_file('profile_edit_left.php')) {
    include 'profile_edit_left.php';
}
include 'frame.php';





This is what i have so far. Decided to go with radio buttons instead.

<form action="edit_form" method="post">
<input type="radio" name="radio" value="1">Option 1
<input type="radio" name="radio" value="2">Option 2
<input type="radio" name="radio" value="3">Option 13
</select>
<fieldset class="controls">
<input type="submit" class="button large" tabindex="100" value="Save">
</fieldset>
</form>

I tried many different codes and i am completely lost, even on adding the query to home.php. Can I use javascript onclick for this? I tried that, I got a lot further but still unsure of what exactly to add
Thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.